How to Setup and Use Github in Ubuntu

If you are or want to be open source developer,you must try GitHub. It is a new hosted Git repository service that's being called a "social network" for programmers. It is basically a distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Setup SSH key

Generate SSH Key

If you have created your account at github and now you want to work with it from your terminal.

Before you start installing Github, you should set up ssh keys:

xiehaozhe@XieHaozhe-Think:~$ cd .ssh
xiehaozhe@XieHaozhe-Think:~/.ssh$ ssh-keygen -t rsa -C ""

And you will get following output:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/xiehaozhe/.ssh/id_rsa): github
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in github.
Your public key has been saved in
The key fingerprint is:
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|   . .           |
|  . E o   .      |
|   o o   +       |
|  o . . S        |
| . + . + .       |
|  o o =          |
|         |
|.. .ooo+o        |

Add your SSH Key to GitHub

Look up your SSH key in file:

xiehaozhe@XieHaozhe-Think:~/.ssh$ cat

Copy the SSH public key to clipboard, and Open

Click "Add SSH Key", and paste your SSH key.


Test connection to GitHub

ssh -vT

If you got an error: Agent admitted failure to sign

For most users, simply running ssh-add to load your keys into the SSH agent will fix this issue.

# Enter passphrase for /home/you/.ssh/id_rsa: [tippy tap]
# Identity added: /home/you/.ssh/id_rsa (/home/you/.ssh/id_rsa)</pre>
If your key does not have the default filename, you'll have to pass the path to <code>ssh-add</code>
ssh-add ~/.ssh/my_other_key
# Enter passphrase for /home/you/.ssh/my_other_key: [tappity tap tap]
# Identity added: /home/you/.ssh/my_other_key (/home/you/.ssh/my_other_key)

Or, you will got a welcome message:

Hi zjhzxhz! You've successfully authenticated, but GitHub does not provide shell access.

Install Git

sudo apt-get install git

Working with git


$ git clone

To configure git

git config --global "Your Name"
git config --global ""

To do a scripts/reconfig, make, perform some changes to the code, ...

git add new_or_existing_file.c
git commit
git push origin master

Occasionally you will want to sync up your fork to the main project branch and pull down any official changes by doing git pull upstream master which is the equivalent of manually doing:

git fetch upstream
git merge upstream/master

You can get more information about Git in:

Contact Us
  • Room 614, Zonghe Building, Harbin Institute of Technology
  • cshzxie [at]