Setting up Github on Linux- 5 mins
Where is this article is going
I am using GitHub for each of my ongoing projects for a long time. Still, every week I discover techniques and the way it could be used to simplify the workflow and I amazed by the thinking behind it. This article is not about what Git is or how it is different from an existing version control system. There’s a ton of video and articles out there describing (or actually fighting, but obviously the winner is Github :) ) about difference systems comparison. Although I would suggest a video by Git creator Linus Torvalds speech on a visit to Google.
If you don’t have an account yet please register one from here and continue to the following steps.
Open your terminal and use following commands to configure globally on your machine.
Replace ‘USERNAME’ with your git username
Replace ‘USER@EMAIL.COM’ with your git email
Setting up the ssh
You can use Git repository over a https connection. But if you rely on it heavily you sure will wish to have ssh connection between your pc and git repo. Mainly this will save a lot of time by skipping writing your username and password every time you want to do an operation.
To generate an ssh key first go to your home directory
Type following command and replace “EMAIL_ADDRESS” with your github email (keep the quotation)
If you don’t have a ssh key folder this command will create one
After that, it will ask for a passphrase along with a confirmation. If you want to learn more about passphrase read this. You should not leave it empty. Remember it or copy it somewhere else. You will need it few minutes later.
If everything is going ok then you will get the following message with a key fingerprint and randomart image.
Now you need to add SSH key to the ssh-agent. Start ssh-agent by this command
This will show an output like this
Now add your ssh private key to the ssh-agent. If you created a key with a different name replace id_rsa with your name. After pressing enter a prompt will be open to give your passphrase. If you give it correctly a meesage Identity added: will be appeared.
You can check your public key fingerprint by running this command
This should return a long list. If not you probably forgot a step or made a mistake. You can also check if the key is working by trying to connect to firstname.lastname@example.org
This will give you a list of possible ssh files and -1 or 0 message beside it. 0 means available and -1 means not available.
On your machine, go to ssh directory and output your key by this
This will show the key. Copy it.
Now go to github settings page and use “New SSH key” button to add the key. On prompt give it a name that you can identify for which ssh is for which machine. And then add key and save it.
This will give you a list of possible ssh files and -1 or 0 messages beside it. 0 means available and -1 means not available.
You might have to close the terminal and reopen to take the effect. Most of the time it isn’t a required step. But it is safe to do once.
After that, if you clone a directory always use ssh version link to do that. If you have an existing repository on your local than to use ssh you have to update the origin address.
Go to the main repo directory of your project on GitHub, under clone or download section open ssh section and copy the link.
On your machine, go to the repo directory and set origin url by this
It’s all done. You can now access and use repository from your machine without explicit authentication.
Some of the resources I hope would be useful
Progit. A recommended book for learning git and its best practices. Download or read
Writing on github file required knowledge of markdown. read from here
I have created a gist of useful commands for using git
Git cli. There’s a few handful premium and free tools out there for mobile and desktop. As because I didn’t used them personally so didn’t included here.
Octotree: An useful browser extension for sidebar listing repo files. Learn more