Imagine software that creates checkpoints in your work and allows you to go back to those checkpoints when you want. This essentially means revisiting your work back in time. Once you are back to such a checkpoint, you can also deviate from the original path that you chose. This is exactly what version control systems do for you!
When using version control, the main code is present on one central repository or distributed over many repositories. Everyone working on the code has a local copy of what they are working on in their local or remote systems. This local copy may be a file, some files and directories or the whole repository, depending on the software. Version control system software helps in the management of this code. Besides that, non programmers can also use such software, for example, to manage documents.
In this post, I will offer a quick review of version control software options that we currently have at our disposal. Version control software is broadly divided into two categories — centralized and distributed. Centralized systems have a single central copy of the code on a server and developers commit changes to this central copy only. In distributed systems, every user has a copy of the code, with full history of the project.
Git, which which is a distributed version control system, is arguably the most popular version control system today. It was developed by Linus Torvalds to address the issue of speed with existing version control systems. A wide range of organizations worldwide prefer Git to manage their code, as Git provides a huge range of features.
With the emergence of popular websites like GitHub, GitLab, and BitBucket, code review using git has become very easy. That is why new organizations are choosing git over others.
Notable internet giants who use Git for version control are Twitter and Quora. In fact, Twitter’s open source work is on GitHub. As of March 2014, their Bootstrap project is the most popular repository on GitHub with about 67,000 stars and over 24,000 forks!
In case you’re interested in the philosophy behind the development of Git, here is a video of Linus Torvalds’ Google tech talk on Git. He talks of the issues with CVS and SVN and how Git solves these.
If you’re new to Git, you can try this beginners tutorial.
Subversion was created as an alternative to CVS (Concurrent Versions System), which has been around for about three decades. Thus, Subversion offers the best features of CVS with some improvements. Subversion puts emphasis on centralized code, whereas other popular version control systems today are “decentralized” (or distributed).
Although it overcomes a few of the deficiencies of CVS, Subversion has a few drawbacks of its own. Subversion is often found to be slow and lacks certain features of its counterparts. For instance, subversions branching lacks many features in comparison with Git or Mercurial.
With Subversion, branches are created centrally rather than in your local machine, which means there can’t be two branches with the same name. As Linus explains in his talk linked above, there can be branches from “test1” to “test5000” too, making it very difficult to understand! Subversion also implements renaming of files in a weird way. It makes a copy of the file or directory to the new name and deletes the one associated with the old name.
Why would you want to use Subversion over Git or Mercurial today if large organizations are moving away from it? Subversion enables you to restrict the access to certain directories for specific users using the path based authorization. The same structure is also possible in Git, but you would have to split your main repository into many smaller ones and restrict access to one of the required smaller repositories. This makes the whole process a bit complex.
For an intro to Subversion you can check out this free book, available online in HTML format or as a PDF.
Mercurial, much like Git, is a free and distributed open-source system. Mercurials main objectives are high performance, scalability, along with advanced branching and merging capabilities. It has advantages similar to those of Git, but there are certain disadvantages too.
Although it started out at roughly the same time as Git, Git has the edge at present. One organization that has shifted from a Subversion server (with a Git mirror) to Mercurial is Facebook. The main reason they chose mercurial over Git is Mercurial’s clean, modular, Python code that was easier to extend. As a result, Facebook engineers contribute actively to Mercurial.
If you prefer Mercurial over Git, you can host your code on BitBucket.
For a beginner’s tutorial on Mercurial, you can check out Hg Init.
Although we have covered the most popular version control systems, there are quite a large number of such systems. One, already mentioned, is CVS (Concurrent Versions System), which has been around since the 80s. It was widely used until the emergence of Subversion and Git. CVS allowed users to register their changes on a first-come first-serve basis and allowed only the latest version of the code to be worked upon and edited. This meant that you needed to commit your code first if you didn’t want to incorporate everyone else’s changes!
Another version control system that I should mention is Perforce. This is a commercial version control system, used by companies like NVIDIA and Ubisoft. Perforce also has a Git plugin to integrate with your existing Git repositories.
Yet another option is Bazaar. Like Git and Mercurial, Bazaar is a distributed version control system and is promoted under the the tagline “version control for human beings”. If you are interested, you can check out their well written documentation.
As evident from this list, you have a lot of options when it comes to version control systems. What you choose to use is largely up to your requirements and to a certain extent, your taste. Generally, people will opt for the system that they have some experience with already. And I should note that many other services like Google Docs provide basic revision control and you should consider a simpler service like that if your needs are minimal.
If you have experience with any alternative options for version control, please let us know in the comments.