Git-svn and branches

I’m using git-svn to leverage the power of git while the rest of the company prefers the simplicity of svn.

I have created a local branch, intending to merge it in the trunk/master when I’m done, but it turns out it’s much more complicated than expected. So, I want to commit it on svn.
I already have checked out the full repository.

The most simple solution I have found; all other solutions fiddle with the git config files, and I don’t like it:

  • Checkout the branch: git checkout mybranch
  • Rename the local branch: git branch -m mybranch-temp
  • Create a remote branch “mybranch” in SVN using Tortoise SVN
  • Fetch the SVN repository to get the new branch: git svn fetch
  • Check that the new SVN branch has been fetched: git branch -r (or git branch -avv )
  • Get back to the master branch: git checkout master
  • Checkout the remote branch: git checkout -b mybranch-svn origin/mybranch
  • Rebase my local branch into the local svn branch: git rebase mybranch-temp
  • Commit the branch in svn: git svn dcommit ; use --dry-run  to check the branch it will commit to, because sometimes it still commits to the trunk (I haven’t found out why).

Use git with your SVN repository

You are just a few simple commands away to start using all the local power of git (local commit and rewind, stash…) over an existing SVN repository.

I say local power, because obviously, SVN being not as powerful as git, you’re still limited in what you can do without breaking everything when you try to commit.

A simple and effective guide can be found here :

Note that on large SVN repository, the first checkout/clone can take hours, or even days. On our 2400-commits-large, several-Gb repository, the first clone has taken a few days, but it was making my (bi-Xeon + 16Gb RAM…) computer hang a few seconds or minutes every 15 minutes or so. Maybe you’ll have better luck.

But once it’s done… it’s really awesome.