Converting Subversion to Git

image courtesy of anarchitect

So you’ve decided to take the plunge and change your version control system from Subversion to Git. We did this a few months ago and have been slowly converting our old subversion repositories to Git as and when we need to revisit them. This article is just as much for our benefit as yours as we’re now doing this more infrequently.

In the directory where you want to create the new git repository run:

git-svn clone --no-metadata -A users.txt -t tags -b branches -T trunk http://path/to/subversion/repo project_dir_name

The users.txt file contains mappings from Subversion usernames to Git user/email combinations. Here’s what ours looks like:

andy = Andy Henson <andrew.henson@foxsoft.net>
hugh_braithwaite = Hugh Braithwaite <hugh.braithwaite@foxsoft.net>
adre = Adre Du Toit <adre.dutoit@foxsoft.net>

You can omit the -t,-b,-T flags if they’re not available in the subversion repository being converted.

Once it’s finished you should now have a new Git repository complete with the version history from Subversion.