Moving Projects from GoogleCode to GitHub

Moving from Google Code to GitHub

The protocol outlined below may appear complex, but it looks more
intimidating than it really is. Moving a project takes about two to five
minutes once your GitHub account and your migration computer is
properly configured.

You need four things to move a Google Code SVN project to GitHub:

  1. A Google Code project to move
  2. A GitHub user account
  3. SSH keys, and
  4. A migration computer that is configured to migrate the
    project from Google Code to GitHub. (in this tutorial, we will use a
    Ubuntu server; but any other Linux/Windows/Mac computer, properly
    configured, should do the job)

Configure Migration Server

The next step is to configure the computer that will be used to migrate the project. For this tutorial, I use a Ubuntu server to do the migration, but any Windows, Linux or Mac computer should do the job if properly configured.

The first step is to install Git and Ruby on that computer:

sudo apt-get install git-core git-svn ruby rubygems

To perform the migration of a Google Code SVN project to GitHub, we are using a Ruby application called svn2git that is now developed by Kevin Menard. The next step is to install svn2git on that computer:

sudo gem install svn2git --source http://gemcutter.org

Migrate Project

Before migrating your project, you have to link the Google Code
committers to GitHub accounts. This is done by populating a simple text
file that will be given as input to svn2git.

Open the authors.txt file into a temporary folder:

sudo vim /tmp/authors.txt

Then, for each author, you have to add the mapping between their
Google Code and GitHub accounts. If a Google Code committer does not
exist on GitHub, then you should map it to your own GitHub account.

 (no author) = Frederick Giasson <fred@f...com>
fred@f...com = Frederick Giasson <fred@f...com>

The format of this authors.txt file is:

Google-Account-Username = Name-Of-Author-On-GitHub <Email-Of-Author-On-Github>

Take note of the first Google Code committer "(no author)" mapping. This link is required for every "authors.txt" file. This placeholder is used to map the initial commit performed by
the Google Code system. (When Google Code initializes a new project, it
uses that username for creating the first commit of any project.)

When you are done, save the file.

Now that set up is complete, you are ready to migrate your project.
First, let’s create the folder that will be used to checkout the SVN
project on the server, and then to push it on GitHub.

cd /tmp/
mkdir myproject
cd myproject

In this tutorial, we have a normal migration scenario. However, your
migration scenario may differ from this one. It is why I would suggest
you check out the different scenarios that are supported by svn2git document. Change the following command accordingly. Let’s migrate the Google Code SVN Project into the local Git repository:

 /var/lib/gems/1.8/bin/svn2git http://myproject.googlecode.com/svn --authors /tmp/authors.txt

Make sure that no errors have been reported during the process. If it is the case, then refer to the "Possible Errors and Fixes section" below to troubleshoot your issue.

The next step is to create a new GitHub repository where to migrate the SVN project. Go to this GitHub page to create your new repository.
Then you have to configure Git to add a remote link, from the local Git
repository you created on your migration computer, to this remote
GitHub repository:

git remote add origin git@github.com:you-github-username/myproject.git

Finally, let’s push the local Git repository master, branches and
tags to GitHub. The first thing to push onto GitHub is the SVN’s trunk.
It is done by running that command:

git push -u origin master

Then, if your project has multiple branches and tags, you can push
them, one by one, using the same command. However, you will have to
replace "master" by the name of that branch or tag. If you
don’t know what is the exact name of these branches or tags, you can
easily list all of them using this Git command:

git show-ref

Once you have progressed through all branched and tags, you are done.
If you take a look at your GitHub project’s page, you should see that
the trunk, branches, tags and commits are now properly imported into
that project.

Possible Errors And Fixes

Fatal Error: Not a valid object name

There are a few things that can go wrong while trying to migrate your project(s).

One of the errors I experienced is a "fatal" error message "Not a valid object name". Here's the issue, you can get the fixed version form here.

Error: author not existing

While running the svn2git application, the process may finish prematurely. If you check the output, you may see that it can’t
find the match for an author. What you will have to do is to add that author to your authors file and re-run svn2git. Otherwise you won’t be able to fully migrate the project.

I’m not quite sure why these minor glitches occurred during my initial migrate, but with the simple fixes above you should be good to go.

[from Frederick Giasson's Blog]

标签:GoogleCode, GitHub, Git

添加新评论