Introduction To Version Control System

This post is an introduction to version control system. We will look at different types of version control system and compare them.

Introduction

Almost all developers use some sort of Version Control System (VCS). A VCS helps a team to keep track of changes to the source code made over time. If you are completely new to the concept of version control system, you might be wondering do I really need to learn this.

Do I Need A Version Control System?

Well, consider the following scenarios.

  • During the development of any software, there are usually more than one developers working together.
  • They make changes to code base and frequently they have to work together on a same file at once.
  • Sometimes code gets added sometimes deleted.
  • New files keep getting added frequently.
  • Developers want to view the original copy of the code base before it was modified by another developer.
  • Furthermore, one developer might be adding feature to a new version of the product while other will be working on bug fixing of previously released version.

These are some of the common situations we come across while working on any software development project. Even if you are the solo developer, you would still come across the situations mentioned above.

A version control system is what rescues us of such situations.

Centralized v/s Distributed Version Control System

Version control system come in two flavors: centralized and distributed.

Centralized VCS

A centralized VCS is built upon client-server architecture.

In a centralized VCS, there exists only one single source repository on the server. All files and changes are stored on that central server. Developers commit their changes directly to the server. You can create branches from the source and merge changes when they are ready.

One of the most popular example of the centralized VCS is Tortoise SVN.

Workflow In A Centralized VCS

A typical workflow in a centralized VCS looks like this:

  • A central repository is usually labelled as “trunk” which contains the stable code base.
  • Team members create a copy of the trunk which is called a “branch“.
  • The branch exists on the server itself.
  • Any development and changes are made on the branch.
  • Once the changes are ready, the branch is merged back with the trunk.
  • Every small change has to be pushed to the server for the VCS to track it.

Disadvantages Of Centralized VCS

The main disadvantage of the centralized VCS arises from the last point mentioned above.

  • Since every change has to be pushed to the server, it restricts the development process significantly.
  • You cannot push changes if you are not connected to the server network. So, you lose the power of version control system if you are out of network.
  • Every branch has to be created in the remote server. This means you cannot have local branch created only for your machine.
  • Team members have restricted right to the central repository and it’s change history.

Distributed VCS

As the name suggest, a distributed VCS does not have a central repository. Every repository contains the complete history of changes. Although you can have a central repository with the distributed architecture also, it is not necessary to have one. This is a radically different approach to traditional centralized repository and provide quite a lot of advantages.

Workflow In A Distributed VCS

A typical workflow in a distributed VCS looks like this:

  • The initial source repository can exist in a server or a local machine.
  • Every clone of the initial source is a source in itself as it contains the entire historical changes.
  • Every team member will have a version of the central repository on their local machine.
  • Multiple branches can be created from local repository on the local machine.
  • Team members commit changes to their local repository.
  • When required, team members can create pull requests to merge their local repository changes with that of the central repository.

Advantages Of Distributed VCS

Distributed VCS like Git have significant advantages over traditional centralized VCS.

  • You are no longer restricted by network to commit small changes. So, you can keep track of the smallest of changes as needed.
  • Commits in the central source repository are less frequent. This reduces unnecessary pull requests and merges.
  • Only final branches can stay in the remote server. Local branches need not be pushed to remote server.
  • Developers can see the entire history of code source.

Git is the most popular open-source distributed version control system in the developers community.

Git - Distributed Version Control System
Git – Distributed Version Control System

Wrapping Up

This post introduced the concepts of version control system and also differences between centralized and distributed system. We looked at the typical workflows and compared the two system.

In the coming articles, we will dive now into Git. Stay tuned!