August 2, 2011 ahydle

Transitioning Subversion to GIT

So it has been a long time coming, I have heard about the benefits of GIT for a while now but have not had time to play with it much. So far I am looking forward to improvements in performance over SVN as well as a more secure implementation to share sections of my repository with colleagues. Lastly I hope at a later date to circle around and build out an active directory/ldap enabled config and to start using GIT to manage Linux configurations; but first I need to get my data out of Subversion.

To begin we need to get a listing of all users who were contributing to the subversion repository. To do this we will run svn log against a locally checked out repository and output it to a file.

svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" "}' | sort -u > authors

Next, edit the file and you should see a line for each user, which looks like this:

jdoe = jdoe

We need to change each user name, adding in the users full name and email address to match the following:

jdoe = John Doe <>

Now we are ready to get the migration going. To begin we are going to use an application called svn2git to do the migration. svn2git can be found at the svn2git website. The following instructions will allow you to install it using Debian/Ubuntu.

$ sudo apt-get install git-core git-svn ruby rubygems
$ sudo gem install svn2git --source

Now that svn2git is installed we should create a working directory and copy the authors file we created previously into the working directory.

$ cd ~
$ mkdir repository
$ cd repository
$ cp authors ~/

Next we are ready to begin the transition to git. Before performing this step please take a look at the command.

  1. My SVN repositories contain everything at the top level, I do not use branches, trunks, or tags so I am using the command –rootistrunk
  2. If you have a more standard repository you may need to alter this.
  3. Please make sure to change the URL to your repo ( to the proper destination for your repository.
  4. Lastly, I had a problem with git svn where the application would bomb out with an error 13. I found other articles referencing the problem and found that just re-running the svn2git command would cause svn2git to pick up where it left off.
$ sudo /var/lib/gems/1.8/bin/svn2git --rootistrunk --authors ~/authors

Now we should have a working GIT repository loaded with all of our subversion data. To test it, I copied out a current version of one of my files and then restored an earlier revision to make sure my revisions came over.

, , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *