Git and Subversion

I'm not a revision control guru, but I've been using Git a lot more than Subversion in the last couple of years. Recently I found myself having to deal with a Subversion repository again. Stubbornly, I began to think about how to use the Subversion respository with Git. I had seen git-svn here and there (for example, I think apt recommends it when you install git-core), and I thought it might have the functionality that I was looking for. It turns out I was right; I now fail to understand why it took me so long to start using this most excellent tool. For those of you that are slow, like me, let me give you a small example of git-svn in action.

  • Clone an entire Subversion repository to your local disk:
    git svn clone local-repo-path
  • Bring this new tracking branch up to date with the original:
    cd local-repo-path
    git svn rebase
  • Create a topic branch in order to fix a bug:
    git checkout -b bug-branch
  • Commit your fix into the topic branch:
    git commit -a
  • Merge the topic branch into the tracking branch:
    git checkout master
    git merge bug-branch
  • Update the original (upstream) Subversion repository:
    git svn dcommit

I'm just starting with this, so the above example probably has problems. If you want to try out something like this, google for "git svn workflow". Here's a nice one:

I'm not going to go into the advantages of using Git rather than Subversion, there are many. And now I can use Git while working with code in a Subversion repository!