Git Tutorial : Part 1( Basics of Git )

Published by admin on

Git basic with examples

In this tutorial, we will learn how to install git on windows and how to link one repository with GitHub . For other operating Systems, installation process will be different but commands will be same.We are using GitHub , but same commands can be used for any other Hosting sites.

Step 1:
Download and install windows installer During installation, make sure to mark “Use Git from the Windows command Prompt” option.
Step 2: 
Create one account at
Step 3: 
Create one Repository on Github clicking on “New Repository” button.By default , your repository will be “public“. On github, you need to pay for “private” repositories.
Step 4: 
Click on “Create repository” and next your repository will be created on GitHub.Open “Git Bash” from “start” and type ls -al ~/.ssh” and hit enter.
If you have already public and private key pairs, you will see file pair like “ and id_rsa” .i.e. same file names but one with “.pub” extension. Then you can skip Step 5, which explains how to create a private-public key pairs if not exists.
Step 5:
Create key pairs:
on “Git Bash” window, enter

$ cd ~/.ssh
$ ssh-keygen -t rsa -b 4096 -C ""
(it will ask to enter file in which to save the key, don’t write anything, just press enter),enter one password, repeat it and hit enter. next one key pair will be generated.You can check them by using “ls” command.
Step 6:
Suppose generated keypairs are “id_rsa” and “
type “clip < ~/.ssh/”
and hit enter, it will copy your rsa key values .
Step 7: 
Next open GitHub, click on your profile icon -> settings -> SSH keys -> add SSH key -> give one title , paste your content inside “key” field and hit “Add key” button. 
Setup on Local Machine : 
Now we need to setup on our PC.
link your “SSH” key of your local PC :
Step 1:
Click on “start” , type “cmd” and open terminal .
Type “git” and hit enter : some messages should appear as below if git was installed properly :
 “These are common Git commands used in various situations:……etc”
Step 2:
Move to Desktop, create one new folder and move to it :

$ cd Desktop
$ mkdir gitTest
$ cd gitTest
Type “git init” and hit enter.
“git init” is used to start using git on any project that is not under git.
Step 3:
Set your username and email, on terminal :

$ git config --global "your name"
$ git config --global "your email"
Step 4:
Move to your GitHub webpage and copy the SSH link of the repository you have created above
Next on your terminal, type ” git remote add origin ry.git “ and hit enter (replace .git link with your copied link).Now your local folder is linked with this repository.
Step 5: 
Create one “readme.txt” file on your repository :
on GitBash terminal, move to your Desktop’s gitTest folder and type

$ touch readme.txt  (It will create one readme file)
$ git add readme.txt"
$ git commit -m "Adding readme file" (one changes is committed locally. Now you should push this change to your git repository.)
$ git push origin master (it will push these changes to git)
(You may be asked to confirm your connection. type “yes” and enter your password )
You can check on your GitHub account , one readme file is added to your repository. 🙂
So in a nutShell :

//Key pair Generation Process :
$ ls -al ~/.ssh
//if key is not available :
$ cd ~/.ssh
$ ssh-keygen -t rsa -b 4096 -C ""

//copy key :
$ clip < ~/.ssh/
//add it on GitHub SSH key settings 
//Move to your folder on local PC
//Configuration :
$ git init
$ git config --global "your name"
$ git config --global "your email"
$ git remote add origin
$ git add readme.txt
$ git commit -m "Adding readme"
$ git push origin master



Categories: git


Leave a Reply

Your email address will not be published. Required fields are marked *