Saturday, 23 July 2011

Why distributed version control is better than centralised 

About a month ago we moved from SVN to Mercurial or rather Kiln to be precise.  Here is the reasons why I believe that the distributed version control model is better than the centralised version control model.

With a central model like Subversion you have to be connected to the network that the Repository is on.  So you can't take your computer out of the office and use the powerful tools that you get with any version control.  You can't commit any changes so if you do a lot of work you have to wait until you are back in the network before you can commit you changes.

With a distributed model then the .hg folder as in Mercurial is a isolated repository which you can commit to at any time. So you get all the benefits of version control  while off line.  Then when you are finally back on the network you can push your changes to the central server.

Now lets think about what happens when a developer starts writing a new application/website.  Normally they will start developing it up until the point they have a stable beta that they can start to show others.  At which time they normally think its time to put it into version control.  With Subversion you go to the central server and you decide to either import the directory of your application or create a directory name and then check out the new empty trunk into a directory in your machine and copy all the files over to that directory and then commit the files.

With a distributed model when you create your directory for starting you project you just choose to "create a repository here" which will add the .hg folder for Mercurial Version control or .git for Git version control.  Then as you are developing up to that stable beta point you can take advantage of the version control tools like commit, revert, diff, etc.  then when you are ready you can connect to your companies central server.  Create a repository on that server for your Application and finally "push" your changes to a central server.

Only when your change sets are pushed to the central server are they generally available.

For a great tutorial check out http://hginit.com