Version Control your code like a boss !

So what is Version Control? 

In simple words version control is a system that helps to record changes to a file or a set of files so that you can recall a specific version whenever required.

Why we need it?

Working in a team and keeping backup of your code and finally publishing it is a real pain when you need to keep backup of all versions of your codes. You also need a huge storage. The below screenshot explains that situation very well.


When I was in college we were a team of five people working on a single project. Distributing work and integrating those was very problematic. We were required to gather together in a single machine and work. So I was searching for a method where we can work collaboratively and also we can keep backup at every point so that if some code gets screwed up we can quickly go back to previous version and start working from that point. was a savior. That time we had no idea about what Version Controlling is and what GitHub is. We just copied and pasted what was written in the help pages and slowly started learning about Git and it's advantages. The GitHub Help Page is very well written and easy to understand.


I personally prefer using Git as a Version Controlling System but there are alternatives.

  • CVS (Concurrent Versions System)
  • Subversion
  • Mercurial

Background of all the Version Controlling Systems 

  • CVSConcurrent Versions System (CVS) is a program that lets a code developer save and retrieve different development versions of source code . It also lets a team of developers share control of different versions of files in a common repository of files. This kind of program is sometimes known as a version control system . CVS was created in the UNIX operating system environment and is available in both Free Software Foundation and commercial versions. It is a popular tool for programmers working on Linux and other UNIX-based systems.
  • Subversion: Subversion, a Apache Project is an open source version control system. It was founded in 2000 by CollabNet, Inc.
  • Mercurial: Mercurial is a open source, distributed version control system, and a compelling upgrade from older systems like Subversion. Mercurial efficiently handles projects of any size and kind. Every clone contains the whole project history, so most actions are local, fast and convenient.
  • GitGit was developed by Linus Torvalds of Linux. The original concepts for Git were to make a faster, distributed revision control system that would openly defy conventions and practices used in CVS. It is primarily developed for Linux.t

As per my experience Git is the best Version Controlling System to use for a project. May be I am a little biased while picking the best one as I have started learning version control using Git.

To start we need Git Bash. Download and install Git Bash on your machine.

Let's init, git init !

The first command to create a git repository is:

git init

Inside the project folder you need to initialize the repository. When you enter the command a .git folder will be created.

Add all your files

git add -A

This command will add all your files to the repository. This is known as staging. -A stands for all files. You can select a particular file to be added to the repository.

git add readme

git add readme


git commit -m "My First Commit"

Now commit your changes to the local repository with a message that can help you remember why you are saving your changes at this juncture. It will by default commit all yours changes to the master branch.


git status

You can check the status of your repository at any point. It will show a lot of information like the list of newly added files, changes that are staged but yet not committed, un-tracked files etc.

git status

Finding your changes

git diff

With git you can see the small changes made in the code. Here is an example. I have a file named helloWorld inside that initially I had written "hello" and made a commit. Now I have changed the content of the file. Instead of just "hello" I have written "Hello World".

Git Diff

Previous Changes 

Now if you want to check your previous commits you can simply type this.

git log

git log

Remote repository

Now we have created our local repository but what if suddenly the hard disk crashes. It's always a good idea to keep a backup of your stuffs in the cloud.

You can host your repository in public cloud or virtual private servers. But if you need a managed git repository there are two major giants where you can push your codes.

  • GitHub : The most popular git repository. It is used by lot of enterprises, open source projects and freelancers. They provide unlimited public repository.
  • Bitbucket : Bitbucket is a Atlassian product. It is widely used by teams of small and medium sizes. They provide free private repositories for limited number of users in a small sized team. It also supports mercurial.

There are lot more things in Git. These are just the basic things you need to know to start working with Git. Later on I will be writing another post to cover some advanced commands.



5 thoughts to “Version Control your code like a boss !”

Leave a Reply

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