Skip to content
Priyanka Yadav

What's a Version Control System anyway?

Software Engineering, Version Control System4 min read

Okay, here's a question and you need to answer it honestly!

Have you ever created multiple folders like v1, v2, v3, v4-final, v5-final-final, v7-last-final, v7-updated-last-final for your project and ended up deleting and updating wrong files every other time?

Well, I have, and it was seriously horrible.

But what were we trying to do in the first place?

Trying to mess up? Come On, No!

We were trying to keep track of different versions of our project, with utmost honesty and creativity.

And if this interests you, Version Control Systems would be good to know about.

So what is a VCS anyway?

VERSION CONTROL is nothing but CONTROLLING THE VERSIONS of something.

Okay, imagine playing a game of chess with your friend. You both are in the middle of a game, but due to some reasons, you need to leave. Now, what's something you would do to continue the game in the future?

Take a picture right?

You would just capture the chessboard, come back later, set up the pieces, and continue with the game again, with no hassle.

chase-clark-IsphRwNKkjc-unsplash.jpg So, what did you just do by capturing that image?

Made sure your friend doesn't cheat? Well yes, why not!

But you also ensured that your game was safe and you could come back to it later, whenever needed.

And that's what a VCS does too, it records the changes in your files over time so you can recall previous versions later on.

Every change is recorded by VCS, along with the metadata, such as who changed it, why they changed it, what was the issue, etc. Just like that chessboard image on your phone, it has all the metadata too, like when the picture taken, what's the size of the image, etc.

Now, the files need not be Source Code files only, they can vary from graphic design images, web design layouts, text documents, or any piece of information.

A VCS gives you the independence of going back to a file, see who did the change and why, the exact timestamp of when the change was made, to easily recover if you messed up with the current version.

Kinds Of VCS

We will learn about 3 kinds of VCS -

  1. Local Version Control System
  2. Centralized Version Control System
  3. Distributed Version Control System

Local Version Control System

In earlier times, when there were no systems such as Git, developers used to track versions by copying files into multiple directories. Yes, just like v1, v2, v3, and so on.

Whenever they wanted to make a change, they used to copy all the old files in a new directory, update the files there, and updated the version number accordingly.

The advantage is that it is really simple.

But the disadvantages are

  • that it is absolutely error-prone, and we have no clue about the reason behind creating these versions, the functionality that was added, etc.
  • there's always a risk of losing all the data if there's no continuous backup.

Centralized Version Control System (CVCS)

Centralized VCS was introduced to make developers work in a collaborative way.

  • In CVCS, there is a single server and multiple clients.
  • The server is a master repository that consists of all the versions of the project.
  • Now, if a client needs to work on that project, he/she communicates with the server and pulls/copies the current version of the project in their local system.
  • If there are any changes in a file or a new version is to be created, the client directly commits them into the main repository.

Two actions are required to make your changes visible to others

  • You commit the changes to the main repository.
  • Others update their working copy to see the changes.

Some famous Centralized VCS are Subversion and Perforce.

The advantages of CVCS

  • Developers can collaborate.
  • They can be aware of the work done by others.
  • Server administrators can control the privileges given to the clients.

However, the biggest disadvantages of CVCS is

  • Single Point of Failure (SPOF):
    • What if the centralized repository goes down? It hampers the development process, and versioned changes could not be saved or updated.
    • What if the centralized repository gets corrupted and there's no proper backup? This may lead to the loss of the complete project.

This disadvantage was the reason that Distributed VCS was developed.

Distributed Version Control System (DVCS)

In DVCS, the client doesn't just pull/checkout the latest version of the code but mirrors the entire repository, including its full history.

This prevents the fear of SPOF since anytime the server dies, any of the client's repositories could be used to recover it.

Actions required to make your changes visible to others

  • You commit the changes to your local repository.
  • You push these changes to the main repository.
  • Others pull your changes in their local repositories.
  • They update their working copy to see the changes.

Some famous Distributed VCS are Git and Mercurial.

Advantages of DVCS

  • Makes collaboration easier
  • Prevents the SPOF problem.

There aren't any disadvantages to using a DVCS as compared to CVCS honestly. But in general

  • If the project has large binary files, a lot of space would be needed to store these files and their versions.
  • If your project has a very long history, downloading the entire history could be somewhat impractical and may also take up large disk space.

Why use Version Control Systems?

  1. Enforces Discipline: VCS enforces discipline since it controls the entire development process.
  2. Archive versions: It also allows you to archive versions, so you can store subsequent versions of the project.
  3. Maintain metadata: Apart from storing the project files, you can also store metadata or historical information about the current and past versions of the project.
  4. Enable Collaboration: The existence of a central repository helps the developers in working together in a collaborative way.
  5. Recovery from accidents: Helps you to cover the mess :P

If you liked the write-up, leave your feedback and suggestions :)