What is version control system – a step by step guide for Git (part 1 out of 3)

what is a version control system

In this part you would learn what is version control system.

The git tutorial is divided into 3 parts, you can download git tutorial pdf (I will provide link soon, right now working to complete second article) if you want to study it offline.

When you search “git tutorial” on google, you would find more than 1 million search results.

So, why I am writing this when plenty of the information is already available?

Well, when I started working on GIT, I have searched a lot, spent a lot of time to learn Git. At the moment I feel that I understand GIT–I stuck in
somewhere either in merging, resolve conflict or sometime in pulling some specific code from history.

There were many occasions when I stuck working with GIT while working in a team. You won’t believe, many time we first take the backup of our working directory before merging anything in that, so we can revert back on working state if anything brake–too annoying, isn’t it?

Most of the articles tell about the commands but do not say why that command is needed, Here, in this article,
I would first write about basics of git, most useful commands of git, why you should use that particular command.

All in a simple language that you can understand and can say that is the best way to learn GIT.

Let’s start with the history of GIT, GIT is a version controls system (VCS) so the first talk about what is VCS.

What is version control system (VCS)?

To understand the VCS – let’s talk what steps usually we do while writing a document, or a blog, or making a powerpoint presentation or writing a code.

  1. You write the first draft of your blog article and then stored in your computer disk in a document.
  2. You come back again and continue writing to complete the article.
  3. Once you are done you might need to send someone else (your colleague or boss or friend) review the document or code.
    He might make some changes in the code and then send back to you.
  4. You again make some changes based on the suggestions you received.
  5. Final draft ready and published on your website.
  6. Someday later you find some better idea about a topic and then you updated the article again to make it more useful.

Now you realized that the suggestion given by your friend in step 3 was not correct. You wrote that text after some research but erased/changed after getting a suggestion.

Oh, I WISH I could have saved–what I changed.

How awesome will it be if you can have the history of all change you made?

Here the VCS comes to SAVE you.

Awesome! There is someone who can remember all of your changes and you can easily retrieve the old version of article or code.

Let’s discuss another case which tells us how important the version control system is–in programming.

How I used to code in my early days of programming. When I was working individually on a project–I usually write code on my local machine and then upload it on development server using FTP. I was working individually so no conflict with another developer.

The problems started when some other developer added to this project. We both work on our own local machine and merge the code at the end of the day on my laptop and then push to the development server.

Looks complicated? Yes, it becomes the nightmare if we both have to do code on the same file.

First, we have to keep talking to each other to know what files we are working upon–trying to do not work on the same file–if we have to work on the same file then we note on which line I make changes.

We prevent this by using file locking or simply avoiding working on the same document that someone else is working on.

It was the frustration of every day until I learned about VCS.

So you now understand what is VCS. Great! if not then read out a detailed definition of VCS on Wikipedia.

Types of version control system–CVCS vs DVCS

#1. Centralized version control system–CVCS

You will have a single copy of the repository in centralized version control system. The project repository will be hosted on a server.
Whoever working on this repository will pull the file that he needs, make changes and then will commit on a central repository. You will never have the full copy of the repository on your local system.

SVN & perforce are some of the popular CVCS.

#2. Distributed version control system–DVCS

With distributed version control system, Every developer has the full project of copy on his local system. He can make changes locally, can commit in a local repository.

If anyone else wants to work on the same project then he can clone the repository on his local system and then can make changes and commit in the local repository.

You can merge the branch of another developer in your local repository if you have access to his repository.

GIT and Mercurial are known DVCS system. In this tutorial, we will learn about the GIT.

To make code sharing and collaboration easy–its recommended to use a central repository. Every developer would work on local, commit on the local repository and then will push the commits on the central repository. Another developer can pull the changes from the central repository into his local repository.

You can create your own server for the central repository or there are many hosted central repository provider available which are widely used for this purpose.

Github, Bitbucket, and GitLab are some popular central repository hosting provider.

List of version control system

There are many VCS software are available, You can see list of version controls system on wikipedia.

Few popular ones are here:

  1. GIT – based on distributed version control system (DVCS)
  2. Mercurial – based on distributed version control system (DVCS)
  3. SVN – based on version control system (CVCS)
  4. Visual Studio Team Services – DVCS–Services for teams to share code, track work, and ship software for any language by Microsoft

What is GIT and why we are using GIT for version control?

You now might have the understanding what is Git, Git is a most popular distributed version control system developed by Linus Torvalds who was the principal developer of Linux kernel.

GIT vs GitHub – Why use GitHub?

We discussed above that GIT is a DVCS but it still requires a central repository to share the code and collaborate on the repository. GitHub is the one of central repository provider website for GIT.

If you are working on a project then you can create a repository on GitHub and then invite other team members to clone this repository to their local system.

Every team member will use git commands to clone the repository, they can commit the changes in their local and can push their updates to GitHub repository by using GIT commands. They can also pull the updates from Github repository to their local system by using git commands.

Bitbucket and GitLab is another tool to host the central repository.

SO, is that enough to understand the difference between GIT vs GitHub?

Not yet?, so here is the one line definition–GIT is the version control tool which needs to be installed on your local system and GitHub is the website application which hosts your central repository and you can use git commands to connect and update GitHub repo.

Wrapping it up

So, we learned what is the version control system, type of version control system, difference between CVCS and DVCS and little about GIT.

If you have any questions, suggestion or correction, feel free to comment below–I will be more than happy to answer and learn.

Soon, I will publish next article to further describe the git and git commands list with examples [published on July 15, 2018].