Version Control Systems (VCS)

If you are in the Software field, you've definitely heard the word "Git". Probably, the first time you've ever heard the word is along the words "Create a new branch. Don't touch the main branch". Don't go watering your office plants if you hear that (I tried to joke. Please laugh:') )! Let's see what it means.

Don't touch the Master

There are developers who are coding/developing/rectifying "features" for a single project (a website or a software or application. An end product). It's going to be very difficult and time consuming building a project single handedly, which is usually why, there is a team of developers. It's also going to be difficult and time consuming if everybody has to code on a single PC, taking turns. Mostly, developers of the company are also in different parts of the world, making collaboration a necessity. 

So, every developer has their own PC. They are coding in their file. As they do so, various modifications take place in the same file. It's also a necessity to keep track of all the changes done in the file. Now how to get the code from that PC? Different place? In another country? Hundreds, maybe even thousands of lines of codes in each PC? Mailing the code? Delivering pen drives to each of these places? Somebody combining all the code received? From all these places? Manually?! Impossible!!

Now, somehow, after doing all this, the team presented the current version to the client, and the client says, "I'd prefer the previous one". What are you going to do? Kill the client? Can't. Sit and delete 1000s of lines of code?  Won't. And then repeat the whole process once again? Die. Well, we can't go bonkers on something so small, yet, such a significant part of developing. This tedious and time consuming process had to be dealt with. 

This works too btw. 

Our brilliant tech minds said, "I know a way" and introduced the Version Control Systems (VCS). Sounds complicated but it makes lives easy. There are 3 types of Version Control System:

  • Local version control system (LVCS)
  • Centralized version control system (CVCS)
  • Distributed version control system (DVCS)

Local Version Control system

The team of developers, code in their respective PCs. Various changes in their respective files should be tracked for easy backtracking. A database is created on the local machine that records changes made to files and directories over time. This allows developers to easily revert to a previous version of a file if needed, compare changes between versions, and keep track of who made changes and when. This is known as Local Version Control System (LVCS). All this happens in a single local machine (Your PC, a developer's PC). It's like the undo and redo options in MS Word but more advanced. 

Local VCS

Central Version Control System

Now, we need to co-ordinate the work among the developers. There are two ways to do so. One is, we transfer the code to a server (another PC), which acts as a Global repository. The code is stored in the server. Each developer has the copy of the saved code (which is the Global repository version) known as working copy. Whenever new code is implemented, the developers perform "commit" to save it to the server (the Global repo). Then, the rest of the team can get the "committed" changes by "updating", basically merging all the changes from the Global repo, in their PC, each time a "commit" happens. This is known as Centralized Version Control System (CVCS). As the name suggests, it has a single or central server where everybody is collaborating on.

Centralized VCS

But there are few drawbacks to this method. Let's go through it:

We mentioned that the code is transferred to a server. The server can be in the local network (i.e. the same location A as the developers) or connected to it via a network (developer in location B connected to the server in location A). When the network fails or the server is down or internet isn't available, a single point of failure (here the single point is a server or Global Repo) occurs (we are unable to access this server) leading to the halt in collaboration and saving of changes, which can delay the whole process.

Distributed Version Control System

To combat this issue, we combined both the Local and Centralized Version Control Systems to form the third type of VCS. Instead of one single repository which is the server, here every single developer has their own server or repository (their own PC). You don’t need to rely on the central server every time. The developer can clone the entire copy of the code to their PC from the Global repository (here, known as Master, which is usually controlled by a team lead), at the start of the project. Now, this is their own repository where they can make changes, which works similar to the LVCS (undo and redo in file). 


Once the developer has completed their work, we need to communicate with the Master (or Global repository), in order to reflect changes in the repository (Global repo). This implies that, the local repository will have 'sets of changes' as you commit modifications, but it is still disconnected with the Master (or Global repo). It doesn't merge the code directly to the Master (or Global repo). So, to communicate (or connect) with the Master (or Global repo), developer can issue a request to the Master and "push" local repository code to the Master repository (which is similar to the functioning of CVCS commit). 

Distributed VCS

Once, the Master (controlled by the team lead) accepts the request, the changes are reflected in the repository (Global repo). Master repository will have different 'sets of changes' from each and every individual developer's repository. The developers working, can access these latest changes by occasionally "pulling" from the Master (update in CVCS). This is known as Distributed Version Control System (DVCS).

We have come to the end of the article. This article was a brief why and what on Version Control Systems. The next article will be about how we can use them to make our lives easier, focusing mostly on the infamous Distributed VCS, Git. 


Keep calm and Don't forget to commit 


See ya soon!

Comments

Popular posts from this blog

Creating AWS EC2 instance

Linux commands - Part II - How?