From Subversion to Git

Yesterday I’ve converted the Asterisk-Java repositories from Subversion to git. It’s rather easy when you use git-svn:

sudo apt-get install git-svn
git svn clone file:///var/lib/svn/repos/asterisk-java \
  --no-metadata -A authors.txt \
  -t tags -b branches -T trunk asterisk-java

The authors file maps the users in Subversion to the git users. While Subversion usually uses a short username, git uses the full name with email address as a globally unique identifier for users. My authors file looked like this:

srt = Stefan Reuter <>
root = Stefan Reuter <>

As I had direct filesystem access to the Subversion repositories I chose to use the file protocol instead of HTTP so it was much faster. The --no-metadata option tells git-svn not to include the orignal Subversion revision number in every commit. This removes clutter from the history.

Finally git-svn creates branches for all tags in Subversion which is a bit nasty. So I converted them to git tags:

cd asterisk-java
for tag in `git branch -r | grep '^  tags' | sed 's,  tags/,,'`
  echo Converting Tag $tag
  git tag $tag tags/$tag
  git branch -r -d tags/$tag

There it is a nice git repository containing the full history. I only had to push it to github to make it available to everybody who is interested:

git remote add origin
git push origin master
git push --tags

Leave a Reply

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