Moving to github from our company-internal svn

Tags: python, nelenschuurmans

We’re slowly moving internal svn projects over to github. I wrote up some notes to help colleagues moving projects themselves. Which can be helpful for others, so I’ve cleaned my notes up a bit and I’m posting them here.

Initial one-time setup

First things first: create a ~/.svn2git/authors file. svn2git uses that to couple svn users with emails known to github. (Update 2011-10-13: I used to say “usernames on github” instead of “emails known to github”, Adam Reeve corrected me in the comments below. He’s right that the username doesn’t matter, you can use a real name.)

Here’s a sample from mine:

# svn_username = Real Name <>
Reinout = Reinout van Rees <>
Gijs = Gijs Nijholt <>
reinout.vanrees = Reinout van Rees <>

If there are usernames missing, svn2git will warn you about it, btw.

Next, install svn2git. See . I’ve copied the instructions for debian/ubuntu here:

$> sudo apt-get install git-core git-svn ruby rubygems
$> sudo gem install svn2git --source

Converting something to github

Create a temporary directory and chdir to it:

$> mkdir /tmp/something
$> cd /tmp/something

Call svn2git on the main directory, not on trunk:

$> svn2git
Using higher level of URL: ...
W: Ignoring error from SVN, path probably does not exist: ...
W: Do not be alarmed at the above message git-svn is just ...
This may take a while on large repositories
W: +empty_dir: Products/Library/timeseries/trunk/doc/source/_static
W: +empty_dir: Products/Library/timeseries/trunk/timeseries.egg-info
Lots of warnings and fatal errors, btw.
HEAD is now at a6be9f3... Tagging 0.7
Previous HEAD position was a6be9f3... Tagging 0.7
Switched to branch 'master'
Counting objects: 367, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (359/359), done.
Writing objects: 100% (367/367), done.
Total 367 (delta 220), reused 0 (delta 0)

Your temporary directory is now a full local git repository. Now we have to make the github repository (“the remote”) and push our repository to it.

Create a repository on github and follow the instructions for importing an existing repository:

$> git remote add origin
$> git push -u origin master

And also push the tags:

$> git push --tags

Then, run git branch to see if there are branches that you want to push over to git as they’re NOT pushed by default:

$> git branch
* master
$> git push origin reinout-experimental

Corner case: moved svn directories

Several of our projects are old enough to have been moved inside our svn repository. Such a move is not something that svn2git likes. In such a case, find the revision number of the move in svn and run svn2git as follows:

$ svn2git --revision 11070

This starts the conversion at that revision number. You do lose the specific changesets from before that time, though.

Removal of old houses for a train tunnel in Delft, the Netherlands logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):