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.
First things first: create a
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 <firstname.lastname@example.org> Reinout = Reinout van Rees <email@example.com> Gijs = Gijs Nijholt <firstname.lastname@example.org> reinout.vanrees = Reinout van Rees <email@example.com> ...
If there are usernames missing,
svn2git will warn you about it, btw.
svn2git. See https://github.com/nirvdrum/svn2git#readme
. I’ve copied the instructions for debian/ubuntu here:
$> sudo apt-get install git-core git-svn ruby rubygems $> sudo gem install svn2git --source http://gemcutter.org
Create a temporary directory and chdir to it:
$> mkdir /tmp/something $> cd /tmp/something
Call svn2git on the main directory, not on trunk:
$> svn2git https://office.nelen-schuurmans.nl/svn/Products/Library/timeseries 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 firstname.lastname@example.org:nens/timeseries.git $> git push -u origin master
And also push the tags:
$> git push --tags
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 reinout-experimental $> git push origin reinout-experimental
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 https://office.nel...nl/timeseries --revision 11070
This starts the conversion at that revision number. You do lose the specific changesets from before that time, though.
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.
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):