Rebase isn't as evil as I thought... and a few other notes.

Recently, on the Bazaar mailing list, a question came up as to whether rebase would be added to the core. My gut reaction was to say “that’s a bad idea” (not that I have any real say on the matter). However, Stephen J Turnbull started chiming in with a few things to help stop the spread of FUD around rebase. In particular, this message sparked my interest.

There were two implications in this statement made in response to rebase not preserving history:

In git, it does, by construction. What it doesn’t preserve is the value of the ref.

The first implication is–at least in my head–If I can’t get to the old ref easily, then I essentially don’t have the history. However, that isn’t the whole story. In my mind, I had always pegged rebase as squashing the commits, which I would consider “destroying history.” Stephen’s statement, made me second guess that. To my surprise, the default behavior of rebase is not to squash the revisions, but to simply migrate your commits. The individual commits themselves are preserved. For me, that’s Good Enough. Yeah, it’s not the “original history”, but it’s still useful.

I still don’t know how I feel about squashing the revisions into just a single revision. On the one hand, if you went through several techniques before deciding on the final one, I kind of want to see that. On the other hand, if you history is just littered with stupid stuff (accidental commits and the like), well… I don’t really need to see that. I suppose that this is where you leave the choice up to the individual developer instead of setting on outright policy (after all, we don’t take away your hammer just because you might break your fingers with it).

FWIW, I really like git (and have for quite some time). It’s list of commands is enormous, but it really does give you quite a number of options in terms of how you’d like to work. I also really like Bazaar. The team has a great workflow, with peer reviews, PQM, and the sheer responsiveness. In the end, I expect that git will be my tool of choice for most personal projects. Bazaar will likely be the one I use most at work, because of the spectacular integration with Subversion, and because it has decent support for Windows. And I expect to be using Mercurial here and there, because that’s what Python has chosen. :-) However, Mercurial integration with Subversion is getting better everyday… so who knows.

BTW, thank you Stephen for encouraging me to take a closer look at rebase. Now that I understand it more, I definitely see its usefulness.

Update: FYI, you should be careful when rebasing and pushing your changes to a public location. It can cause some issues. Google ‘git rebase push’ to see some examples and read some blogs as to why.