Use the power of git to develop with both git and svn

Sun 27 December 2009 by Thejaswi Puthraya

I was one of the thousands who jumped on to Google Code when it was released sighing a relief that Sourceforge was no more a Hobson's choice.

But very soon github was released and showcased git's amazing power. Again like the thousands, I too switched but this time I really wanted to mirror the github changes to Google Code rather than orphan the repo. This would ensure that I could utilize the power of git (mainly local branches for development).

So here is a step by step procedure of how to go about it (mainly as an archival purpose after having struggled for more than two hours). You need to have git-svn installed to be able to fetch the changes from google code for the initial code:

# Clone the google code svn repo first
$ git svn clone https://<google_code_project_url>/trunk checkout_name --username=<google_username>
$ cd checkout_name
# Add a remote to github and fetch
$ git remote add -f -m master git_origin<username>/<git_project.git>
# Track the 'master' remote branch on github
$ git branch -t github remotes/git_origin/master
// Make the changes in the master repo (say)
# Commit from the local 'master' branch to google code
$ git svn dcommit
# Move to the local 'github' branch
$ git checkout github
# Merge the changes from master into github
$ git merge master
# Push the changes to github
$ git push

Not very difficult but slightly cumbersome to repeat! Google Code offers mercurial support but I have not had an opportunity to work it.