Understanding Git Basics

Git 101

One common requirement which occur quite often in all the Software Engineering job description is Git. Git has become an essential skill for both developers and testers. So lets see the basics of git and how to get started with it.

Image for post

Git is a Version Control System. A version control system is a software that manages all the changes that occur in a code over a period of time. Whenever a file is edited, it makes a copy of the file and save it as checkpoints. If any of the edits needs to removed or rolled back, these checkpoints becomes incredibly useful to go back to last saved state and proceed from that. Its like a eraser. There are many version control systems available in the market. However, git has gained the spotlight , thanks to its “distributed version control” feature.

So, What is a distributed version control?

There are two types of version control.

  • Centralized Version Control
  • Distributed Version Control

Centralized Version Control

Image for post

Concept — There is only one central copy of the project in the server. All the commit is performed to this central copy.

How it works

  • Pull down the changes if any from the central server.
  • Make your updates and test it for bugs
  • Commit your updates to the central server for other programmers to see.

Distributed Version Control

Image for post


Each programmer has his own copy of the project and will work on it in the local repository.

How it works

  • Instead of doing only the pull down of changes from the repo, the programmer clones the entire repository from the server to his local repository.
  • Each programmer works on his local copy of the project, updating it by creating a branch.
  • Pull request is initiated to perform team work on the updates.
  • Once the updates are approved, push commit is used to update it in the server.
  • In case of the server fails, any of the client repositories can be copied back to server to restore it.

Basics Terminologies

  • Repository — It is a directory or a folder used to store your projects. There are two repositories

1. Local Repository — This is your local copy. The changes and updates you do to the files wont be reflected in the server until you do push and commit.

2. Remote Repository — This is repository in the server that can be viewed and accessed by all.

  • Push — It is used when you want to update the project in the remote repository
  • Commit — Submitting the files in the local repository. This is more like a check in or save option. If you are from SQL background you would be familiar with this.
  • Pull — It is used to download the latest update or the copy of the project from the remote repository. This command usually downloads the file from the remote repository and merge it with the file in the local repository.
  • Master — When you create a repository, git creates a branch and by default its called master. Master points to the commit you have made in the project and it always points to the latest commit.
  • Stage — This is one term you will often come across while researching about git. As simply as it can be explained, staging is a phase before the actual commit. It prepares the file for the final commit. Metaphorically speaking, imagine a product, say vegetables. The farm where they are grown is your local repository. The store to which they are brought to sell is the staging phase. You buying it and taking them home is the commit.
Image for post
  • Origin — This is the link between your local and remote repository. It is like a watermark. When you clone a remote repository , git creates a connection called origin, which refers to the remote repository which was cloned.
  • Clone — As simple as the name itself, it means copy. When you click clone, you are creating a mirror image of the repository into your local machine.

So, you have created a GitHub account and have created a repository. Now you want to clone it, but you see the options “Clone” & “Download”. Whats the difference between clone and download. Well, clone creates a copy of the repo into your local machine with all the git files.You can work on those files, see the history of commits, update the files and push it to the remote repo and much more. Download on the other hand simple copies the files without git. You can only see the latest commit. You cannot develop further and update it in the remote. It is like your copy and thats it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: