Centralized vs Distributed Version Control: Which One Should We Choose?

Version Control: Developer’s Best Friend

Guide to choose the version control system that works for you!

Shashank Thakur
The Startup

--

What is version control?

I can’t state enough how important the version control system is for software development. It is very important how we track changes in our system. We need to pick a version control that suits our needs. Let's dive in!

What is Version Control System

A version control system is basically a software tool that helps you track and manage changes to source code with time. Version control systems track every kind of change made by the developer. If something goes wrong, a developer can always go back in time, compare it with an earlier version of code, and fix it. This way the impact on the team is very minimum.

When developers work on a project, we add your features to source code. In the process, the value keeps getting added. Source code becomes very valuable and we can’t afford it losing it for any reason. Having a version control helps protects our source code from both catastrophe and unintentional human error and their unintended consequences.

Why we need a version control system

Developing software without a version control system is like having no backup. Not using a version control system for software development is a recipe for a disaster waiting to happen. Let's talk about some benefits of version control system

1. Detailed History of Every Change of Files

Version control system helps us keep track of each and every change of the file, whether it is deleted, create, or any modifications. While the application is continuously developing it is very likely we will break things. Having a detailed idea of the exact changes along with the corresponding file name, we can easily track down the root problem and then fix it easily.

2 . Collaboration

Software development usually happens in teams. So we collaborate with other devs to accomplish a common goal. It is quite possible that more than one dev is working on the same file. With version control, they can work independently on the same file. VCS will help to integrate changes and create a unified copy. With a VCS, everybody on the team is able to work absolutely freely on any file at any time.

3. Switching between version

With help of VCS, we can easily go back and forth between versions of our codebase. This is very useful say if did some mistake we can always revert. Also, think of the scenario that you want to try out a feature that is in progress, you can easily do that too.

Types of Version Control Systems

There are basically two types of version control systems

1. Centralized

Centralized Version Control System

In a centralized version control system, there is a centralized codebase. As a developer when you work on a file, you pull it down, make the change, and update the server copy. You never have the entire code base on your local machine, only what you need. One popular example of a centralized VCS is Subversion (SVN).

Pros

  • Easy to learn and use
  • With everything maintained on a centralized server, the client or our developers doesn't need to clone the entire repository. Cloning a huge repository could become an issue on the client's hard disk.

Cons

  • Since the entire code base is maintained in centralized localization, if the centralized server crashes, there is always a risk of losing the entire code base.
  • Slower than Distributed Version Control as for every interaction with any file, network calls are made back and forth. As a result, it is slow.

2. Distributed

Distributed Version Control System

With a distributed system, we don’t rely on a server to have all the versions of project files. We clone the repo locally and maintain a full history of the project. We make changes to the local copy, commit our changes to the local copy. At this point, we are disconnected from the server/master copy. We have some local sets of changes that aren't part of the server/master copy. In order to sync that with the master copy, we will make a pull request change which we merge to master. Getting changes from the master copy is called pull and pushing changes to master/server copy is called a push. Eg of DVC is git and mercurial.

Pros

  • Speed — It is very fast because anytime a client makes changes to their copy of the repository, it is all local, there is no network calls made back and forth. But as compared to CVCS(Centralized Version Control System) there is a network call made with every change to sync with the server.
  • Offline Access — The beauty of a distributed system is since the client accesses the file locally on their machine, they don't need internet connection all the time apart from pulling and pushing the code.

Cons

  • Learning Process — Using a distributed version control system has some learning curve. For eg, you have to learn how to use basic commands. Central Version Control is a little easy to use.

Conclusion

Version control is a very crucial piece of software development. Especially when you work with a team of developers. While it is always possible to make software without version control, but that would be a recipe for a disaster to happen. Always use version control regardless of the size of the project or the number of collaborators. Use the version control system that makes sense for your needs.

--

--