Another view of the merge versus rebase debate in version control

June 3, 2012

One of the persistent debates in modern version control is between merging changes and rebasing them, with the customary pro-merge argument being that rebasing destroys history. From the developer's view this is completely correct; rebasing destroys the history of the changes that are being rebased, causing them to spring into existence fully-formed.

But there's another view you can have on this; you can have the view of a user of the repository, someone (or something) who is pulling and tracking the tip/head of the mainline. And from this user's view, the history that merges preserve effectively doesn't really exist. Before the merge commit it wasn't there at all, and when the merge commit was made all of the changes appeared instantly from nowhere (and they appeared as an indivisible whole; as you step back and forth through the history of the mainline tip, you either have all of the merge or none of it).

The important thing to understand is that this 'user' perspective always sees a linear history of the repository (unless you're doing something very unusual with head/tip), in that every time they update the head marches forward along a continuous unbranching line of development. This means that from the user perspective, a merge is functionally equivalent to a single giant rebase commit; both have the same net effect of causing a large indivisible block of changes to show up all at once.

(A merge is theoretically superior to a single giant rebase in that you can perhaps bisect back through a merge to find a specific broken change. But you should never do single giant rebases; you should rebase with a sequence of single-change commits, which makes bisect even simpler and more likely to actually work in practice.)

Thus I think it's clear that from the user view the best thing is a series of rebased commits. Although they may appear all at once they look as much as possible like separate changes, and as separate commits you can still look at the changes individually and step through them one by one if you need to (and similarly, bisect through them).

Sidebar: a general problem with merges and bisecting

There are a number of practical problems with bisecting through merges, but a general one is that once you start bisecting into a merge you are no longer working in the mainline code. From the user view this means that you are in completely unfamiliar territory where even if the code theoretically works it may lack changes, bugfixes, or features from the mainline that you need.

(The more long-lived and isolated the branch was, the more you may run into this.)

Written on 03 June 2012.
« My view on Mercurial versus Git
Why the TTY line discipline exists in the kernel »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Sun Jun 3 22:51:58 2012
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.