What is Distributed Version Control System?

Learn via video courses
Topics Covered

Overview

A version control system is a tool in software development that tracks the changes in the code, documents, and other important information regarding a certain code base (or project), etc.

There are two types of Version Control systems:

  • Centralized Version Control Systems (CVCS)
  • Distributed Version Control Systems (DVCS).

In DVCS every client has a copy of the project on the local system as well as on the central server. Since the data is stored on our local hard drive, all the operations can be performed very quickly. The distributed version control system can be managed very easily as compared to the version control system i.e. centralized version control system.

Pre-requisites

The prerequisites for learning the distributed version control system and how can Git be visualized as a distributed version control system can be a basic understanding of Version Control Systems, and Git. Let us discuss them briefly.

A version control system is a tool in software development that tracks the changes in the code, documents, and other important information regarding a certain code base (or project), etc. Now if we want to recall any certain previous version of our project, we can use a version control system. When we have a version control system, with use, we do not need to be worried about losing our previous data. A version control system not only helps us to track the files and manage the files but also helps us in developing and ship the products faster.

Some of the advantages of the Version Control System are: improved visibility, team collaboration around the world, improved product delivery, and traceability for every change ever made. Helix Core, Git, SVN, ClearCase, Mercurial, and TFS are some examples of VCS. Now since the development of the software is increasing day by day, the team size has increased, and things become more complex. So a version control system is quite useful.

There are two types of Version Control systems: Centralized Version Control Systems (CVCS) and Distributed Version Control Systems (DVCS). Let us first learn about the Distributed Version Control System (DVCS) in the next section.

What is a Distributed Version Control System (DVCS)?

To understand a distributed version control system, let us first look at the problem with the normal approach of saving versions of a certain project. In general, people make copies of the project and save them in a folder naming the version number of the project. For example, the first version of the project is saved in a folder named version_1. Similarly for newer updates, we can name the versions as version_2, version_3, and so on. Since this approach is quite easy and simple, people highly use this method but this method has a lot of problems: if we write a wrong version number or if we have forgotten to copy all the necessary files, etc. So we must use a version control system like distributed version control system.

Now, with a distributed version control system or DVCS, the clients need not check out the latest version of the snapshot of our files. Here, the DVCS completely mirrors the repository which includes the entire history of the repository. So, we can say that every cloning of the project means that the entire data of the project is cloned.

A DVCS is similar to Git. The DVCS uses the machine of the user to replicate the entire repository of the user. Here various users are given the privilege to access the master repository which promotes continuous integration.

Please refer to the image provided below for more clarity. what-is-a-distributed-version-control-system

Now, what is a repository? Well, a repository is a folder or directory that can store files of various types like (HTML files, CSS files, Python files, C++, files, images, documents, databases, etc.). We can also include a license and a README file that keeps the information about the repository.

As we can in the example above, every developer involved has a copy of the master repository (that can be served on a server like GitHub) on his/her local repository. A developer can make changes in his/her local repository and then push the changes to the central one. Now, the other developers can pull those changes, and hence all can work on the same plane. In this method, developers do not check out the snapshot of the source code but they completely mirror the central depository itself.

Thus we can say that the data is not only stored on the central server and we do not need to rely on the central repository. Every developer has a copy on the local system so if the central data is lost, any developer can push their data into the central server and things will become normal.

By the term pushing, we mean uploading our data from our local system to the central server (the central repository is updated with the data of the local repository). And by the term pulling, we mean downloading the data from our central server to the local system (the local repository is updated with the data of the central repository).

What are the Advantages of Using a Distributed Version Control System?

So far we have learned a lot about the distributed version control system, let us learn about the various advantages of the distributed version control system.

  • Since, the data is stored on our local hard drive, all the operations can be performed very quickly. Only the push and push operation is associated with the central repository so they take comparatively larger time than the other operations.
  • We can first commit the changes to the local repository and after committing all the changes on the local system, we can altogether push the changes to the central server as a single snapshot (as a single new version of the project).
  • In the DVCS system, every developer has a copy of the entire project so there is no need to be worried about losing the data.
  • Since, the entire project is available for each developer, he/she can test the entire project and the changes before pushing it on the central server. this avoids any crash of the project.
  • DVCS provides us a unique identifier known as GUID or Global Unique Identifier that helps us to make the changes quite effectively. It also helps in easy tracking and versioning.
  • The distributed version control system can be managed very easily as compared to the version control system i.e. centralized version control system.
  • We can visualize the distributed version control system as a tree-like structure where the central (remote) repository can be treated as the trunk and the various developer's local repositories as branches. This tree-like structure helps us in easy merging and branching.
  • We can work on our project even if are offline as we have data on our local system.
  • We do not need to manage a lot of things in the distributed version control system. DVCS itself takes a snapshot of the changes and we can revert or refer to any version of our choice.

There are some minor disadvantages associated with the distributed version control system as well.

  • Although the repository contains its revision number we need to associate a tag for the releases. This can create confusion.
  • In DVCS we still need a backup as all the developers do not have the latest updated version.
  • If our project becomes large, its binary files will consume more space and hence it will be difficult to compress the files.
  • Large files also consume a large memory in our local system.
  • We need to rely on the central server and hence without a central server, the DVCS is hard to be managed.

Why is Git a Distributed Version Control System?

Git is one of the most popular distributed version control systems that track the changes in the code, documents, and other important information regarding a certain code base (or project), etc. Git also follows a tree-like structure for keeping track of the changes and for versioning the project.

Git is a pretty fast distributed versioning system that provides several commands for its developers. Its features and high performance makes it widely used in the enterprise world. An organization's team of developers may be working on various locations so they can use this distributed version control system for their development purpose. With Git tracking our files in the background the developers need not be worried about losing files while adding new features or experimenting.

Let us briefly discuss Git and its features. Git is free and one of the most widely used version control systems. We can use Git through the command line as well as through its graphical user interface (GUI). The command line or terminal version of Git is known as Git Bash on the other hand the GUI version of Git is known as Git GUI. Git tracks the changes in a project and saves a certain state that is known as commit. A commit is a snapshot of the file's current version(s). So, we track these commits and can revert to a certain commit if we want.

Some Common DVCS Examples

A distributed version control system helps developers to work independently and lets them store their changes in their local system as well as on the central server. Some of the examples of the most commonly used distributed version control system are Mercurial, Git, and Bazaar.

Distributed Version Control (DVCS) vs Centralized Version Control (CVCS)

There are some problems associated with distributed version control systems. Nowadays companies are switching to a centralized version control system as the centralized version control system is developed to deploy multiple high-performance servers hence fulfilling the needs of a large global organization. So, these are some of the reasons why people switch to the Centralized Version Control (CVCS).

Let us now discuss some of the differences between the distributed version control system and the centralized version control system.

DVCSCVCS
DVCS stands for Distributed Version Control System.CVCS stands for Centralized Version Control System.
In DVCS every client has a copy of the project on the local system as well as on the central server.In CVCS, every client needs to download a copy of the project on the local system for work.
DVCS is comparatively hard to learn for beginners.CVCS is comparatively easier to learn and set up.
There is a lesser number of chances of merge conflicts in the DVCS system.There are more chances of merge conflicts in the CVCS system.
Working with branches is easier in the DVCS.Working with branches is comparatively harder in the CVCS.
We can even work offline using the DVCS system.We cannot work offline in the CVCS system.
DVCS is faster as data is stored on the local system.CVCS is slower as data is not stored on the local system.
In DVCS, we do not need to completely rely on the central server.In CVCS, we need to completely rely on the central server.
In DVCS even if the central server is down, our workflow is not halted.In CVCS if the central server is down then our entire workflow is halted.

Conclusion

  • A version control system is a tool in software development that tracks the changes in the code, documents, and other important information regarding a certain code base (or project), etc.
  • Some of the advantages of the Version Control System are: improved visibility, team collaboration around the world, improved product delivery, and traceability for every change ever made.
  • There are two types of Version Control systems:
    • Centralized Version Control Systems (CVCS)
    • Distributed Version Control Systems (DVCS)
  • In DVCS every client has a copy of the project on the local system as well as on the central server. Since the data is stored on our local hard drive, all the operations can be performed very quickly.
  • The distributed version control system can be managed very easily as compared to the version control system i.e. centralized version control system.
  • The DVCS uses the machine of the user to replicate the entire repository of the user. Here various users are given the privilege to access the master repository which promotes continuous integration.
  • The distributed version control system can be managed very easily as compared to the version control system i.e. centralized version control system.
  • We can visualize the distributed version control system as a tree-like structure where the central (remote) repository can be treated as the trunk and the various developer's local repositories as branches.
  • Git is one of the most popular distributed version control systems that track the changes in the code, documents, and other important information regarding a certain code base (or project), etc.
  • With Git tracking our files in the background the developers need not be worried about losing files while adding new features or experimenting.