You are here: Home / Blog / posts / Pixelworkers of CAES DO / SVN to Git

SVN to Git

by pgang — published Sep 16, 2011 11:40 AM, last modified Jan 28, 2014 02:54 PM
Converting a subversion repository over to Github!

It's been awhile!! I'll keep this post short, because in fact there are a ton of other guides on how to do this out there. But I'll put the highlights here and a few notes that I wish had been explained further.

So what's this for anyway? The old Plone UC Davis skin had been hosted in a Subversion repository at (requires CAS authentication) which was fine and dandy, but someone brought up that it might be better served at Github, so that it'd be public and others can contribute to it. Having little experience with Github and even less with svn, I thought this would be nigh impossible. Turns out I was wrong! Check it out —

  1. Credit where it's due

    In preparation of the move, you need to properly map the usernames of anyone who had commit code to the old svn to their accounts on Github. Luckily, someone made a handy script to figure out the list for you:
    svn log --quiet | grep '^r' | awk -F\| '{print $2}' | sort -u > committers.txt
    That'll output all the svn accounts (email addresses, in this case) to a text file. Then, just add the associated Github accounts in the following format:
    svn account = real name or account name <github account email address>
    i.e. = feesh <>
    or: = Mr. Man <>
    It took me a few tries to get this right, because I assumed Github would recognize just the account name. Not so! It needs whatever email address they used to sign up for Github to associate it with the correct account.
  2. Bring in the code!

    Next up, you copy everything from that svn repository to your disk or wherever.
    git svn clone <svn repo url> --no-metadata -A committers.txt -t tags -b branches -T trunk <destination dir name>
    I'm not sure what all those add ons are, but the -A pulls the account mapping file you just made and makes the switch for you, I think.
  3. Clean up on aisle three?

    In order to resolve some formatting differences between git and svn, you need to manually convert some branches into tags. When you go into the new .git directory you just made running that git svn clone above, you can run
    git branch -r
    and see all the branches you have. Some of them are called tags/blahblah — these are the ones that need to be switched over. So for each of those, run the following:
    git tag blahblah tags/blahblah
    git branch -r -d tags/blahblah
    Which I think makes the new tag, and then deletes the old branch.
  4. To the cloud!

    Once that's all ready, you can push the whole thing up to Github. This is just the normal, register the repository bit, i.e.
    git remote add origin
    git push origin master --tags
    I think the last --tags part is the only difference, maybe.

Anyway, that's all! The repository is good to go from Github — — Mostly straightforward, neh? If anything looks incorrect over there, I'd appreciate it if you let me know!