How I setup Git on my Windows machine

Step by Step Guide

Step 1 : Download Git bash .

Step 2 :Type the following command :

git config --global user.name "your_username"
git config --global user.email "your_emailid"

Step 3 : Generate SSH-key using the following command :

ssh-keygen -t rsa -C “your_emailid”

If prompted for questions like Enter passphrase (empty for no passphrase):

Enter same passphrase again: I have kept it blank.

Output should be something like below followed by a random art image.

The key fingerprint is: SHA256:…. 

Step 4: Now go to your Windows user directory under C:\Users\{Username} .

You will observe a .ssh folder is created containing two files

  1. id_rsa(private key)
  2. id_rsa.pub(public key)

Always keep the private key with you and never share it .

Step 5: Go to the directory where these keys are stored using the following command :

cd c/Users/{Username}/.ssh/

Step 6 : Type the following

cat id_rsa.pub

This will spill out the contents of the file.

Output should be something like ssh-rsa …..

Step 7: Go to Github account in your browser

Account settings > SSH and GPG keys > Click New SSH key > copy paste the contents from above command in key section > Add key

Setup Done .

Step 8: Now test it

ssh -T git@github.com

You should get an output like this .

Hello {Github Username} You’ve successfully authenticated, but GitHub does not provide shell access.

Step 9: Go to the directory where you want to setup local repository and type the following command

git clone git@github.com:{Github Username}/{Github Repository name} .git

Everything should work fine if step 8 has been successful.

Please comment in case of any suggestions/mistakes/issues at 
gautam.onlycode@gmail.com.