To perform a merge, Git needs to figure out what exactly happened in two branches from a common ancestor ( A1
). As you said correctly, Git stores snapshots of commits / trees in order to get the actual set of changes, it has to compare A2
with A1
and B1
with A1
, and then combine these separate sets of changes.
The same thing happens in rebase. To apply change set A2
to B1
, we first need to calculate that the change is set from the differences between A1
and A2
. And then we can apply this to B1
. You can think of rebase as something like automatically creating patch files. First, it generates all these patch files from the old branch and applies them to the current HEAD.
So, we need all these three commits in order to actually calculate the differences, since we cannot understand what happened in the commit just by looking at this message.
poke
source share