From Git (github) to svn (googlecode)

By Christopher, August 7, 2010

We decided to move bajos from github to googlecode at therefore I need to port our repo. The task import from git to svn could be done in this way:

From  http://code.google.com/p/support/wiki/ImportingFromGit

Most of this is copied from the google page, but they are writing about continuous mirroring, I want to show, that the same procedure is useful for a one time import!

The Subversion repository must be nonempty. A new Google Code project contains one revision by default, but if you reset it, you should also create a first revision.

Naturally, your official source tree lives on some Git-capable server, which we denote by $GIT_REPOhttp://code.google.com/hosting/createProject creating a new Google Code project, initialize an intermediary repository and fetch the Git tree:

 $ git svn clone --username you https://your-project.googlecode.com/svn/
 $ GIT_REPO=git@github.com:hwr-berlin/bajos.git #example!!!
 $ cd svn
 $ git fetch $GIT_REPO

Create a temporary branch for the fetched repository, and tag its head:

 $ git branch tmp $(cut -b-40 .git/FETCH_HEAD)
 $ git tag -a -m "Last fetch" last tmp

Unfortunately, Git treats the initial commit specially, and in particular, cannot rebase it. Work around this as follows:

 $ INIT_COMMIT=$(git log tmp --pretty=format:%H | tail -1)
 $ git checkout $INIT_COMMIT .
 $ git commit -C $INIT_COMMIT

Apply all the other commits to the temporary branch, and make it the new master branch:

 $ git rebase master tmp # takes a while
 $ git branch -M tmp master

Lastly, commit the changes to Google Code:

 $ git svn dcommit # depending on your repo size it could be a run some hours

I had problems during the dcommit because of some bug on googlecode. My commit cancels at some point. If you have the same problems check:

http://blogs.gnome.org/diegoe/2009/03/18/saving-your-neck-when-git-svn-dcommit-fails/

or:

http://groups.google.com/group/google-code-hosting/browse_thread/thread/e0a6597f7f4c7739?pli=1

I need to do it several times.

Important you need the last hash (HEAD) from your git repo!!!

What do you think?

You must be logged in to post a comment.