Git Plus SVN Aug 10

I like subversion. I like git more. At work, we’re on subversion. Here’s how I work with subversion through git:

Repository Checkout

  # r1234 is some revision within the recent past, like a week ago.
  git svn clone -r 1234

  # Update repo to current HEAD
  git svn rebase

  # Tidy up some space
  git gc

Daily Routine

  # Update to HEAD
  git svn rebase

  # Branch for feature development
  git co -b cool_new_feature

  # ... do work and commit changes ...

  # Checkout master and update
  git co master
  git svn rebase

  # Rebase the branch
  git co cool_new_feature
  git rebase master

  # When your feature is ready:
  # Merge into master
  git co master
  git merge cool_new_feature

  # Check into subversion
  git svn dcommit


If you do a git svn clone and do not specify a revision, git will check out each revision one by one until it reaches SVN’s HEAD. You do not want to do this with a large repository, unless you really want to sit around for a few days.