Navigation ( archives ›› 2011 ›› April ›› 05 ›› Never use git-svn to convert your SVN repo to Git )

Never use git-svn to convert your SVN repo to Git

Posted on April 5, 2011, 6:13 pm EST

If you want to convert your SVN repository to Git, the first thing that you would try is the native built-in git-svn that comes with your distribution. Think twice when you use that approach on a 1GB SVN repo with many branches and tags, it will take forever. It took around 8 hours for my repo.

Problem with git-svn

  • Doesn't convert it as a bare repository, sure we can just look into .git folder.
  • It doens't respect the standard layout for tags and branches. You have to pass those values in.
  • Doesn't allow you to use an irregular layout. For example, it doesn't understand if you have two trunks, or folders in root. We have to just stick with trunk, branches, and tags. Nothing more.
  • It doesn't even understand what a tag is, it treats it as a branch. You have to create a script after its complete to manually tag those branches that should have originally been branches.
  • SLOW, flithy slow!


I didn't give up finding a better way. Even though it worked, I kept on searching online for alternatives. Every single script and solution that users have created use git-svn. Where are you Google, you didn't help at all! I was more curious how the bigger organizations have done the conversion. First thing that came to my mind was KDE. I remembered KDE becuase I used gitolite before and they were on the list of adopters.

KDE is very old open source "true" project. When I mean "true", I mean, everything they do is in the public. I respect that in the highest level. Every feature they create, they communicate with the community. Every decision they make, the community is involved. Absolutely no corporate black box that is hiding how they do their project from the community, unlike many projects that I have seen. By saying these words, makes me super excited that I wanted to contribute to KDE. KDE converted their 64GB SVN repository in around 1 hour! I screamed in my mind when I heard that, 1 HOUR!!!! It took me around 10 hours to convert 1GB. Since they are open sourced, they documented every step along the way!

Native svn2git

They called it, svn2git (the real one, too many fake clones out there that I tried and all use git-svn), and they have a nice wiki to explain how it is done

It is a C++ Qt application that communicates directly to the SVN repository. It is super fast, when I mean super fast, I converted my 1GB SVN repository in a matter of minutes, under 5 minutes! From 10 hours to 5 minutes! This hidden tool is so powerful that it should really be known.

How to use it

In Red Hat Enterprise, it is a pain I had to modify some code to backport it to Qt 4.0. RHEL don't support Qt 4.7, they just support Qt 4.0 which is quite sad. But luckily, the code for svn2git was open source and beautiful! Easy to understand and easy to know where everythin is. It was my first time looking at Qt code, and to tell you the truth, it is beautiful!

Running it is pretty simple, all you have to do is:

qmake && make
./svn-all-fast-export --rules samples/standardlayout.rules ~/svn/

Within a few minutes, the whole SVN including their tags, branches, and trunk converted! git-svn didn't do that!

Yes, I am super happy, I can now create complext rules to convert my SVN repo to a multiple Git repos to make the organization better.

About this Article:

Comments (0) - Add yours, or View the replies

Categoy (Software)

Views (15884)

Digg it: Digg this article