A quick git-svn tip

February 1, 2008 – 6:52 am

Updated!

When preparing to merge a working branch back to master (so that you can push it up to your SVN repository), the following process may be helpful:

> git checkout -b working
[work work work]
> git commit -m “helpful message”
[work work work]
> git commit -m “another helpful message”
> git svn rebase (pull down others’ updates - this is the updated step)
> git checkout master
> git svn rebase (pull down others’ updates)
> git merge –squash working
> git commit
[delete metadata, leave helpful messages]
> git svn dcommit

The output of all that is an SVN commit reading:

Squashed commit of the following:
another helpful message
helpful message

If you supply an explicit commit message to the last git commit (the one in bold), however, it will override your squashed messages and your SVN log will show only the final outcome, instead of all the steps you took to get to it. Of course, you could also leave the metadata from the squash - but that ends up generating a lot of noise in the SVN log.

Updated!
If your working and master branches are on different SVN revisions, you’re more likely to run into trouble during the merge, so it seems like a good idea to rebase both before trying to combine the two.

Thanks to my coworker Clinton for this addition!

  1. 2 Responses to “A quick git-svn tip”

  2. I do not trust git-svn. Not after it decided it was cool to lose 3 days worth of code when I tried a git-svn rebase before a commit.

    By João Marcus on Mar 13, 2008

  3. Ack! Luckily, I haven’t had that happen - I’ve run into other issues, but nothing irreversible.

    By Ben on Mar 13, 2008

Post a Comment