Git commands

Connect github using ssh key pair

Generate ssh key pair

$ ssh-keygen -t rsa -b 4096 -C ""

Follow the steps, we suggest you to leave all the setting to defaults. When passphrase is asked enter one which is very good and secure.

Go to your home directory where keys have been generated with name id_rsa and

Copy you public key

Add the copied key to Github

In top right corner of ny page, click your profile photo, then click Setting

In the user setting sidebar, click SSH Keys

Click Add SSH Key

In title field, add a descriptive label for new key.

Paste your key intot the Key field

Click Add key

Confirm the action by entering your Github password.

Test the connection

Open Terminal (Ctrl + alt + T)

$ ssh -T

If successful you will see message as below

Hi username! You've successfully authenticated, but GitHub does not

provide shell access.

In local do following

$ ssh-add ~/.ssh/id_rsa

Configuring PC to work locally

In your PC, configure username and email with following command

$ git config --global "YOUR NAME"
$ git config --global "YOUR EMAIL ADDRESS"

Make a directory in which you will work and initialized git

$ mkdir ~/docs
$ cd ~/docs
$ git init

Add remote

$ git remote add origin

Renaming remote

$ git remote -v
$ git remote rename origin destination
$ git remote -v

Deleting existing remote

$ git remote -v
$ git remove rm origin
$ git remote -v

Remove directory from git and local

$ git rm -r one-of-the-directories
$ git commit -m "Remove duplicated directory"
$ git push origin master

Above will remove folder from remote repository but not local.