An Intro to Distributed Version Control

There are a multitude of reasons why distributed version control systems (like Mercurial and Git) are potentially preferable to centralized systems such as CVS and Subversion. One is that branching is cheaper and merging works much better. I only have anecdotal evidence of this. Frankly, I use Git only for personal projects (in the sense that I’m the only one working on them). For WebDSL (which I work on with a couple of other people) we use subversion and there we hardly ever branch, because “merging works so badly”. Which, I suppose is true, but I’m hardly a subversion expert.

Quite out of the blue, Joel Spolsky (of Joel on Software and StackOverflow fame) has published a Mercurial tutorial online. And even if you don’t give a rat’s ass about Mercurial, I suggest you do read at least the first “chapter”: Subversion re-education, which points out the differences between the subversion and mercurial/git mindset:

Want to know something funny? Almost every Subversion team I’ve spoken to has told me some variation on the very same story. This story is so common I should just name it “Subversion Story #1.” The story is this: at some point, they tried to branch their code, usually so that the shipping version which they gave their customers can be branched off separately from the version that the developers are playing with. And every team has told me that when they tried this, it worked fine, until they had to merge, and then it was a nightmare. What should have been a five minute process ended up with six programmers around a single computer working for two weeks trying to manually reapply every single bug fix from the stable build back into the development build.

And almost every Subversion team told me that they vowed “never again,” and they swore off branches. And now what they do is this: each new feature is in a big #ifdef block. So they can work in one single trunk, while customers never see the new code until it’s debugged, and frankly, that’s ridiculous.

Keeping stable and dev code separate is precisely what source code control is supposed to let you do.