What is Git ?

Git is a version control system. In simple terms it is a solution to make code management easier. With GIT we can revert back to any changes in any past time made to code easily and quickly. Using GIT and Amazon Code deploy any changes made to Git master will be automatically deployed to our production or testing server and made live automatically.

Key Terms in GIT

  1. Repository – Repository means a directory where all the code files are present. In simple terms think of it as a simple directory on your computer where all your code is stored.

There can be 2 types of repository

  • Remote repository(origin) – Our main repository on Github.com where all the code is stored on the remote server at Github.com
  • Cloned local repository(master) – Your local copy of the main Github remote repository.
  1.  Clone You can clone the remote repository on your local computer for making any changes to the code. Once the copy from the server is cloned locally you can than make the changes to the code locally and do the commit and than push the commit to remote repository.
  1. Commit – In GIT, commit means you are finalizing the changes to the code locally and committing it after all the changes to the code are made. Doing git commit “records changes to the repository”.
  1. Push git push means all the changes that you have made to the local repository after committing are updated to the remote repository.
  2. Master master is your primary branch on your “local” computer repository to which you have to commit the changes. Committing to master means all the local changes made to the code are updated in the main master. You can push it later to origin as well.
  1. Originorigin is the primary branch on your “remote” repository, by convention it is the ‘primary’ centralized repository as well. By saying git push origin branchname you’re saying to push to the origin repository.
  1. Origin/masterorigin/master is a remote branch (which is a local copy of the branch named “master” on the remote named “origin”)
  2. Branch A branch is like your separate branch where you will be working on coding it. This way you do not have to interfere with the main master workings.
  1. Clone – Clone means, you are cloning the online repository on your local computer for doing any work on that coding locally..
  1. Fetch – You can use git fetch to see if there are any updates to the remote branch without necessary merging them with your local branch.
  1. Pull – In the simplest terms, git pull does a git fetch followed by a git merge. git pull pulls from a remote branch and merges it to the local branch.
  1. Merge – merge means to merge to separate branches together and make it the same. You can merge the branch to the master branch after doing all the changes to the copy in branch.

How to Install GIT

If you are windows, goto https://windows.github.com/ and install the Github software. After installing the software, you will get 2 separate softwares.

  1. Git GUI
  2. Git Shell

Git GUI can be used to clone the repository on your computer for the first time and login to your github account. For all other purposes we will be using GIT shell, which is like the real professional coders way to maintain the code.

Basic GIT shell commands to get you started. Follow once step by step and you will learn the way to use GIT.


  • Creating branch:  Command: git branch neeraj – This command creates a new branch with name neeraj.
  • Changing branch/Checkout branch: Command: git checkout neeraj – When you login to GIT shell you are at master initially. After typing in this command, you are now moved to branch named neeraj.
  • Note: Now Delete a file locally by going to explorer. This will delete the file from just the branch named neeraj and not from local master branch.
  • git status – Check the current status of neeraj branch. A message with Untracked files will appear on the shell. Untracked message is received when the file is not found or new file is added to the local directory via explorer.
  • git add –a  – This command adds all untracked files that includes deleted or newly added files to git branch
  • git commit -m ‘file deleted locally on neeraj branch’ – Once the untracked files are added you can than commit the final code with the commit message that you like. -m parameter in commit is for writing the message.
  • git push origin neeraj Push the local branch neeraj and commit it to the origin that is remote repository at the github.com. This will create a branch named neeraj on remotely at origin and push all the changes in remote.
  • git checkout master Now goto local master using shell.
  • git merge neeraj – This command merges neeraj branch to master branch locally. That is now the local branch named neeraj and master are absolutely same.
  • git status – Check status of master branch. It will tell that you are ahead by 1 commit to master.
  • git push – Since we are ahead by one commit. To keep in sync we will push all the updates in local master branch to online GitHub master by using git push.

This is the basic set of commands of git. Also there is another interesting set of command

  1. git pull – Does both git fetch and git merge
    This command first fetched the content from the remote and than merges it with local copy. That is it syncs remote and local copy.
  2. git fetch – Only fetches the changes and tells you what is the difference between remote origin copy and local master copy of git.
  3. git revert <commitid> – This is the command to enter to revert back to your old commit and go back to the changes you did earlier. Every commit that you make has a unique commitid.

Commands to get started. (Create, clone, update, revert git repository)

  1. Create Repository on Github – After get login in github you will find a +(plus) icon section. Click it to create a new repository, Follow the below screenshot for referral purpose.


  1. Add collaborators or contributors to your repository – After creating repository you will a find setting menu at the top section by clicking on which we can add collaborators for our repository


  1. Clone Repository : Clone repository by link: We can directly clone the repository using the link to repository. Follow the below screenshot for brief.


  • Clone repository using bash command:


  1. Opan bash terminal or command prompt.
  2. CD to directory where you want to clone.
  3. Clone your repository: git clone <repository url> This command is used to clone your repository in local for example you can refer to below screenshot.
  4. Now you have cloned the master branch to your local computer. And we need to do initial commit to sync our local computer branch to remote .
  5. To do initial commit we need to follow the below command.
  • Enter command echo “# Tst” >>README.md
  • Enter command git add README.md.
  • Enter command git commit -m”initial commit”.
  • Enter Command git push origin master.
  • Now your initial commit is updated to remote repository.

Update local repository and from remote repository with git:



  1. cd to repository directory.
  2. Enter command git pull(to update local copy).

Update Changes on local and remote repository with git:



  1. Perform any changes under repository local folder and do any changes eg: file create update delete.
  2. Then Add changed files contents to the index: enter command git add –a.
  3. Then commit your changes enter command git commit -m”your changes description”.
  4. Then update remote repository: enter command git push


Revert to commit:


  • To revert to particular commit id we use command :  git reset <commit id>  eg:  git reset –hard 4e5f3c128cbb36bcd04ad919cc39a7acab3dad60
  • Git push -f origin master(This command is used to sync the changes after reset to main branch)

This is how your Team Lead can generate manual for there team, So that team can work in more effective way.  

As this is the first time we are making all document, So we are in process of Improvisation. So time to time we improvise this draft.

Get More Knowledge: