Migrating a SourceForge Subversion Repository to GitHub

One of greatest attractions of GitHub is the community and the tooling that allows this community to share code. It’s all down to Git of course but the presentation and traction that GitHub offers makes it a very compelling choice for an open source project looking for a home.

Universal Password Manager has been hosted on SourceForge since it’s launch in December 2005. Over the course of those years there have been many patches offered by generous developers looking to help improve it. While merging these patches is usually straight forward I can imagine how difficult it would be if the project was very popular and had tens or even hundreds of contributors.

GitHub offers a very attractive alternative. Each contributor can clone the repository, make their changes and then send you a pull request. As the project maintainer your job is now a whole lot easier and more manageable. No more patch files to worry about. Everything is organised and fully traceable.

For this reason (and so that I can use and learn more about Git) I decided to move UPM’s code from SourceForge to GitHub. These instructions are nothing new. There are plenty of similar posts. What I’m offering here are the steps I went through from start to finish.

1. Install svn2git. This involves installing git, ruby and ruby gems. Full instructions are available here.

2. Create a link to svn2git

$ sudo ln -s /var/lib/gems/1.8/bin/svn2git /usr/bin/svn2git

3. Copy down your project’s subversion repository to help speed up the migration process. SourceForge make this very easy by providing an rsync daemon. See here for details.

$ rsync -av upm.svn.sourceforge.net::svn/upm/* .

4. Create an authors file. This is used to map the authors in your Subversion repository to those you want to use in Git.

adrian = Adrian Smith <adrian@email.com>

5. Create a new Git repository for your project. This will be a local repository for now so there’s no need to worry about GitHub just yet.

$ mkdir my_project
$ cd my_project
$ git init

6. Run svn2git. This process can take a while (hours if your repository is exceptionally large). What it’s doing is reading each Subversion revision and creating a corresponding Git commit.

8. Create your new GitHub repository as described on this page following the Existing Repo? instructions.

Since we’ve gone to all this trouble we might as well leave a little message on SourceForge redirecting visitors interested in the source code to the new GitHub page.

1. Logon to SourceForge and go to Project Admin -> Feature Settings.

2. Select Manage next to Subversion and go to Non-SF.net Resource (Active). This page allows you to leave a short message and a link to the new project page. It’s unfortunate there’s so much talk about Subverison on this page but the Git feature doesn’t have the option of redirecting visitors to an external host.