Subversion to git migration

I have done a major project trying to migrate a large open source (Geomajas) from subversion to git. The conversion did not actually happen as the community voted against it, but there were quite a few lessons learned along the way.

To import the subversion repository, you need to create an authors file specifying the e-mail address for each committer. It looks something like

joachimvda = joachim Van der Auwera <dude@example.com>
other = Someone Else <otherdude@example.com>

You can then use the following command to import the subversion repository

mkdir backend
cd backend
git svn init --trunk=https://svn.geomajas.org/majas/trunk/ --tags=https://svn.geomajas.org/majas/tags/ --branches=https://svn.geomajas.org/majas/branches/ https://svn.geomajas.org/majas/trunk/
git svn fetch --authors-file=../authors.txt 

If you get the following exception on the fetch

perl: /build/buildd/subversion-1.6.6dfsg/subversion/libsvn_subr/path.c:115: svn_path_join: Assertion `svn_path_is_canonical(component, pool)' failed.
error: git-svn died of signal 6

then you have to remove the double slashes after the urls in your .git/config file.

You can just redo the “git svn fetch –authors-file=../authors.txt”.

Once the import from subversion is done, you can set the remote.
git remote add origin GIT_URL

And you can then push that using
git push -mirror origin master

After that you are ready to work. You can re-synchronize with the base subversion repository using

git svn rebase
git svn dcommit

Unfortunately though, this does not work seamlessly when pulling in changes from both the remote git repository and the subversion repository. As git-svn is rewriting the commits (to include subversion revision numbers), commits will be undone and redone continuously. The “git svn rebase” may force you to do a “git rebase –skip” a couple of times.

If you rrepository includes many maven modules which need to be released separately, you will need to hack a little to make this work. The scm tags in the maven project do not allow you to specify a base directory in the repository. This causes your entire repository to be tagged (no big deal) and checked out for the release build.
The solution is to stop the build during the “mvn release:perform”. Then

cd MODULE
cd target/checkout
cd MODULE
mvn -DperformRelease deploy

git push –tags

As I said in the beginning, the migration was denied. Apparently, the git support in eclipse is sub-par, which would make it more difficult to use for some some of the core developers. There are some tests with Mercurial ongoing as we speak. We'll see how that goes. Sonatype is also working on an improved egit for Maven IDE, maybe that is also an option for the future.

One Comment

  1. balder says:

    Thanks ! I encountered git-svn died of signal 6 when commiting a squashed commit (of about 50MB removal and 20MB adding )

    Goolge led me here. svn rebase did the trick.

Leave a Reply

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

*

question razz sad evil exclaim smile redface biggrin surprised eek confused cool lol mad twisted rolleyes wink idea arrow neutral cry mrgreen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>