You are here

A complete idiot’s guide to git-svn-migrate

Submitted by John on Wed, 2010/09/01 - 9:48pm
3 steps to batch convert Subversion to Git

If you read my previous post about converting Subversion repositories to git, you’ll know that to do a proper Subversion-to-Git transformation on a batch of repositories is going to take some time (what with all that command line typing). I had 142 legacy project Subversion repositories lying around I wanted converted to Git and, since I’m lazy, I pulled on my bash boots and wrote me a script to do the work!

With the git-svn-migrate scripts I wrote, you can batch convert all of your Subversion repositories in just 3 steps. And I’ve GPLed them and put them on GitHub if you’d like to collaborate and improve them; see the git-svn-migrate project page.

svn boxes go into the factory; git ponies come out.
git-svn-migrate: a reverse glue factory

0. Download the git-svn-migrate scripts

This isn’t really one of the 3 steps, but obviously you need the scripts. You can either download the latest official release from GitHub or you can get the most recent development release by cloning the repository:

git clone git://

1. Create a list of Subversion repositories to convert

Create a file called “repository-list.txt” with one Subversion URL per line:


With this format the name of the project is assumed to be the last part of the URL. So these repostitories would be converted into awesomeProject.git, secretProject.git and evilProject.git, respectively.

If the project name of your repository is not the last part of the URL, or you wish to have more control over the final name of the Git repository, you can specify the repository list in tab-delimited format with the first field being the name to give the Git repository and the second field being the URL of the Subversion repository:

awesomeProject    svn+ssh://
evilproject     file:///svn/evilProject

With this format you can use any name for the final Git repo. In the first example above, we’re using the second-to-last part of the URL instead of the last part of the URL. In the second example, we’re just changing the name to all lowercase (recommended). And in the final example, move along. Move along.

2. Create a list of transformations for Subversion usernames to Git committers

Using the repository list created in step 1, run the script to create a list of unique usernames for all the commits in your repositories. The output of the script should be redirected to a file.

./ --url-file=repository-list.txt > author-transform.txt

Edit the raw list of Subverions usernames to provide full names and emails suitable for Git committers. The output of the script will be of the form:
username = username <username>
You should edit each line to be:
username = Full name <email>

For example, change:
jwilkins = jwilkins <jwilkins>
jwilkins = John Albin Wilkins <>

3. Convert the Subverion repositories into bare Git repositories

This is the easiest step. To place all of your new bare Git repositories in /var/git, simply run:

./ --url-file=repository-list.txt --authors-file=author-transform.txt /var/git

This may take a while. (My 142 repos took about 6 hours to convert.) But you’ll see the progress as the underlying git-svn pulls commits out of all of your Subversion repositories.


Posted in:


Mark's picture

I just started working with git. Though, it is pretty safe against corruption and all, it is somewhat hard to follow. Git svn migration is painful when you are not thorough with git in the first place. But your three step conversion is totally idiot proof. A life saver it is. Even though it took me quiet a few days to figure it out completely, in the end it was worth it. And hey where can I find an idiot proof tutorial to git?! Mark

I had problems using this with an HTTPS-based SVN repo, as git-svn doesn't support a non-interactive password prompt. Problem was solved by making a small script which simply does: echo 'password', and running as follows:

GIT_ASKPASS=$PWD/askpass ./ --url-file=repolist.txt --authors-file=userlist.txt /var/git

Downside is it means (at least temporarily) storing your password on disk, but you can always shred the file later.

m-ric's picture

I run into a problem where I got following output:

fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

It happened when issued 'git svn show-ignore --id trunk >> .gitignore;' command.
I don't know svn at all, and it took me some time to figure out that my repo url was wrong... I got that url from pjproject ( Removing the /trunk prefix made my day. If anyone got into similar issue, check your svn repo url.

Thanks for those scripts, very useful :-).

steve's picture

Awesome...worked beautifully. Thanks soooo much for doing the work to put these together, and of course for making it available to everyone. Note that in your instructions on this page, in step 2 there is a small typo: the command should be "./", and not "./" - author needs to be plural. Easy enough to fix, but I thought you might want to know.

Add new comment