Exporting an svn repository to git format

To have good scientific results, it must be possible for other researchers to replicate what one’s found (or maybe it was a fluke). Along these lines, psychology articles have long included very detailed sections on methodology that should allow other researchers to recreate similar experimental settings. For projects that involve custom-made software tools, this should be even easier, because the researchers can share the exact code they used on a public repository. Yet this is almost never done, even for pure computer science research.

When I became Principal Investigator of the Computational Social Cognition program at A*STAR in 2008, we created and maintained all our custom software using an in-house Subversion (“svn”) repository. The policy was and still is that one can pursue open-sourcing of a project if it turns out not to have any commercial potential; it’s been my aim since 2008 to open-source as many of our projects as we can, and try to start a movement in cognitive science research to share in this way. Other researchers share this view.

My new site intentionperception.org is the next step. In addition to all the non-code resources it houses, I want it to link to source code from all researchers in this topic who are willing to share, and I want to put them all on a project-hosting site that will be around a long time. I considered SourceForge, GitHub, CodeHaus, and GoogleCode, and decided that Git’s local repos offer many advantages over svn, and that GitHub’s issue tracker and community are more mature and active than others.

So how to convert our svn repo project to git format? The svn2git tool is nearly ideal, but I had to make some adjustments:

  1. Although the readme indicates the following should be sufficient for installation,

    $ sudo apt-get install git-core git-svn ruby rubygems

    $ sudo gem install svn2git

    I found that some of these packages failed to install, and prevented those that followed them from installing, and did so silently. So I recommend doing sudo apt-get install on each item in the first line separately.

  2. The readme also indicates that one can indicate a particular project in the svn repo to convert without having to checkout and convert the entire repo. But I ran into errors such as:

    [...] is not a complete URL and a separate URL is not specified.


    pathspec 'master' did not match any file(s) known to git

    So I did a complete checkout and conversion of all projects in the svn repo, but I will checkin only some of them to github. Deleting the .git folder in the current directory and then retrying helped. Our root is the trunk, and we have no branches; none of the tags is worth keeping, either. So the command that worked for me was:

    $ svn2git -v http://mydomain/svn/repoName/ --trunk / --nobranches --notags --username myusername

  3. But actually that wasn’t enough, either, because svn2git seems not to send KeepAlive’s to the server and I was timing out with this error:

    RA layer request failed: REPORT of '/svn/repoName/!svn/vcc/default': Could not read response body: connection timed out (http://mydomain) at /usr/share/perl5/Git/SVN/Ra.pm line 282

    One of the unexpected benefits of exporting from an in-house repo is that I could file a ticket requesting that the server timeout be temporarily increased. If I were converting a SourceForge repo, I might have to wait until svn2git is fixed instead.

  4. Now you should be ready to import.

btw, doing all this with Ubuntu 13 in VMWare Player 6 on Windows 7 64-bit works fine.

Print Friendly, PDF & Email