Switching an SVN repository to Git using git svn

Converting from an SVN repository to a Git repository is fairly simple—you just want to move all the commits across, preserve your tags and branches, and make sure all the commit authorship translates properly. The simplest method (though not always fastest) is to use the git svn command to do the full conversion. (Note also that you could interact with an SVN repository with Git as the middle man using git svn... but this blog post is just about doing a full conversion).

Converting the authors

Before you convert the SVN repository to Git, you need to get a list of all the SVN commit authors, and then set up the list for git svn to be able to translate SVN commit authors to Git commit authors (the Git format is slightly different, using a name + email combination). First, in a terminal window, run the following command within a local checkout of the SVN repository:

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

Next, edit the authors.txt file and change lines to match Git authorship information. So a line like:

johndoe = johndoe <johndoe>

Might be transformed into:

johndoe = John Doe <[email protected]>

(The values for the name and email would correspond to what you set in Git using git config --global user.name and user.email).

Converting the repository

At its simplest, the git svn command just needs a few arguments:

git svn clone SVN_REPOSITORY_URL --no-metadata -A authors.txt --stdlayout LOCAL_DIRECTORY


  • SVN_REPOSITORY_URL is the URL of the SVN repository you're converting.
  • authors.txt is the path to the authors file you just created (assuming you're still in the same directory as you were when you created it earlier).
  • LOCAL_DIRECTORY is the directory where the git repository will be created (with the latest master branch revision checked out).

Note that files from the master branch (along with a .git folder) will be checked out directly into the local directory; so create an empty folder for this step!

Caveats for non-standard SVN layouts, preserving tags, etc.

Because SVN isn't very strict about where things go, and how you can structure branches, tags, etc., you will likely run into situations where you need to tell git svn about weird branch layouts, or tags that don't conform to any rational standard (or have weird characters in their names).

In these cases, please check out John Albin's excellent and more fully-detailed article on Converting a Subversion repository to Git.

Alternative conversion methods

One major downside to git svn is the time it takes to do the conversion—for small repositories having less than a few hundred commits, it's not an issue... but I've had to convert repositories with hundreds of branches, thousands of tags, and over 10,000 revisions. Initial testing found that the conversion took over 5 days on a pretty fast machine directly connected to the SVN server! I would recommend you check out how to convert the repository using SVN2Git, a super-fast SVN to Git conversion application created by the KDE team. What takes days could take minutes using SVN2Git.