I had an interesting thing happen using git, wondering if anyone could explain it to me so I can understand better.
When doing a merge of multiple branches (A,B),
git merge A B
fails as non-fast-forward, while
git merge B A
worked well. Why would that be?
Let’s assume that A is a strict, direct child of the current branch. Then assume that B is a strict, direct child of A.
The octopus merge, which processes heads given as arguments from left to right, incrementally with respect to the tree, but independently with respect to the index succeeds without conflict if it tries to apply B and then A, but encounters a conflict if it does the converse.
As per the
git-mergemanual, section MERGE STRATEGIES:For instance:
Indeed, when fast-forwarding to A, the label of master has not been pushed forward, though the tree has.
If, looking at the code of what the octopus merge does, I perform this manually (look above for hashes):
In the other direction (
merge B A), now, if you look again at the code of merge-octopus, it tries to detect the branch we are trying to add is already in the tree (secondcaseof theforloop). Indeed, at the merge of A, it sees ac5b51c (a.k.a. A’s head) is the common ancestor of A and B, and aborts without doing the secondread-tree.This behavior is consistent with the fresh version of git : though I’ve pointed to v.1.3.1, this is still happening with my version.
tl;dr : you want your octopus merge branches to touch distinct files