Collective SVN project -> GitHub

More and more Plone projects are being migrated over to GitHub for various reasons. Here’s a quick guide on how to import your Collective SVN project into GitHub.

GitHub can directly import SVN projects only by specifying a URL to the repository. However, for some reason this does not work for Collective SVN repositories. The import screen keeps processing but nothing happens. You are left with the manual approach of migrating a Collective SVN repository to GitHub.

GitHub account

Naturally, you first need an account at GitHub. Go register if you don’t already have one!

Git repository

Next you need to create a git repository. Login to GitHub and go to your Dashboard. Follow the New Repository button in the right-hand portlet and fill in the required fields. Click Create Repository. Great, your git repository is now ready!

Instead of creating a new git repository in your own account, you can also consider creating one in the unofficial “Collective” GitHub account – an experiment by a few fellow Plonistas to recreate the Collective spirit on GitHub.

Authors

Before proceeding you need to compile a list of people that committed code to your project. Do that by inspecting output of svn log http://svn.plone.org/svn/collective/<your.project>. Create a file called authors.txt where you map all SVN committers to GitHub users:

zupo = Nejc Zupan <[email protected]>

The format of the mapping is svn_username = git_username <git_email>. You can also generate this list automatically.

Using plone.org’s author page usually gives good enough results for connecting SVN usernames with real people:

http://plone.org/author/<svn_username>

First commit revision

The Collective SVN repository is huge. As of this writing, it has over 240k commits. Running “git svn clone” over the whole history takes quite some time. To speed things up, write down the revision number of the first commit in your Collective SVN repository. Inspecting the oldest entry of svn log http://svn.plone.org/svn/collective/<your.project> will give you this number.

Import

There are many tools and approaches you one can use to perform migration from svn to git. This guide uses git-svn. While it has some limitations (branches and tags won’t be migrated) it does it’s job. All you need to do is run the following 4 commands:

$ git svn --authors-file=authors.txt clone -r<first_commit_revision>:HEAD -s \
http://svn.plone.org/svn/collective/<your.project> <your.project>
$ cd <your.project>
$ git remote add origin [email protected]:<your_git_username>/<your.project>.git
$ git push origin master

There, your project now happily lives inside a git repository on GitHub. Access it by pointing your browser to https://github.com/<your_git_username>/<your.project>.


Big thanks to Martijn Pieters of Jarn and Kai Lautaportti of HexagonIT for helping me out with my first steps using git and GitHub, you guys rock!

Useful links:

Neyts Zupan

Neyts is the Digital Overlord of Niteo, poking his nose into any and all technical things.

See other posts »