Skip to content
 

Source code management for personal projects

After hearing all the buzz about distributed version control systems (DVCS), I was curious if they offered advantages over subversion for personal code management. The answer is a resounding yes, and I see no reason to ever go back. I considered three candidates: git, mercurial (hg), and bazaar-ng (bzr).

With distributed version control, the central repository is no longer king. Every user can download a copy of the repository and start their own tree. They can also publish their tree, and if they’ve done a good job improving the software other people will pull from them. Central repositories can still be implemented, but they are no longer necessary. Typically a main repository is still presented to users of the software, but behind the scenes every developer has their own complete tree. This may sound like it will create a merge nightmare, but the DVCS tools make merging easy. This in turn encourages frequent merging, which also makes for simpler merges.

It turns out that the way this is implemented is great for personal projects. I will use git as an example – mercurial and bzr are almost identical. This is how you add source code management to your project with git:

cd my/project
git init
git add .
git commit -m "Initial Import"

What this does is create a .git directory in your project root. This directory is the repository. You can edit code, git add the modified files, and then git commit, just like with subversion. I no longer have to create and manage external svn repository directories, and I don’t have .svn directories polluting my tree. Mercurial and bzr also create a single top-level directory for the repository (.hg and .bzr, respectively).

All three candidates have excellent documentation and very similar commands for basic SCM tasks. For personal projects, I think all of them work very well and there is no clear stand out. All three can import an existing subversion repository. git-svn allows you to pass change sets back and forth between a subversion branch and a git repository, so you can use git even if the project must remain in subversion. I think mercurial and bzr have similar tools.

Dave Dribin has an excellent blog post discussing some of the pros and cons of each system. He chose mercurial. I also recommend the linked youtube video of Linus Torvalds talking about DVCS. Most of it is not specific to git, and Linus does a good job of explaning how DVCS is different (and better).

Some thoughts:

  • The main drawback of git right now is that it’s Linux/Unix/OS X only. It will run in windows with cygwin, but apparently it’s very slow. Mercurial and bzr run fine in windows.
  • bzr has a reputation for being slow. It sounds like newer versions are much better, but still not as fast as git and mercurial.
  • git has very lightweight branching, and allows you to concurrently work on different branches within the same working directory. This might be possible with mercurial and bzr, but it is not an emphasis in the documentation.
  • git, unlike any other SCM, does not track specific files – it tracks the data inside the files. I still don’t fully understand what this means, but I have some sense of how git uses this to handle renaming. If you move a file or directory in git, it will not change the SHA1 hash (which represents it’s content and history). This has advanges over explicitly tracking a rename. In particular it makes merging easier and reduces the chances of a merge conflict (see Randal Schwartz’s git talk).
  • As a consequence of tracking content rather than files, git is slower than other systems at generating histories and logs for a single file. You will probably not notice this unless you have a very huge repository. Linus recommends breaking up huge projects with submodules to avoid this problem. For other tasks git has a reputation for being screamingly fast.

I chose git. If you are still having trouble choosing, I recommend taking recourse to the banal. “bzr” is really annoying to type. “git” is only slightly harder than “hg”, but since “git” is properly pronounced like “get”, I find myself typing “get” when I mean “git”. Therefore mercurial, with it’s compact “hg” command, is the superior scm.

One Comment

  1. I was able to use this blog as a resource for a talk at the university. So thanks for this.

Leave a Reply