You want the --all
option to git-merge-base
. From the documentation:
-a, --all
Output all merge bases for the commits, instead of just one.
This will show all the merge bases that will be used to create a temporary tree as a recursive merge base.
For example, consider some branches 'A' and 'B' that were criss-cross merged:
3a4f5a6 -- 973b703 -- a34e5a1 (branch A)
/ /
7c7bf85 X
/
8f35f30 -- 3fd4180 -- 723181f (branch B)
It's clear that branches A and B have two common ancestors that were involved in a criss-cross merge: 3a3f5a6
and 8f35f30
. git-merge-base
will choose one of the common ancestors as a merge base, but using the --all
flag will include both:
% git-merge-base A B
3a3f5a6ec1c968d1d2d5d20dee0d161a4351f279
% git-merge-base --all A B
3a3f5a6ec1c968d1d2d5d20dee0d161a4351f279
8f35f30bfe09513f96cf8aa4df0834ae34e93bae
In this situation, as you note, git-merge-recursive
would merge the two merge base to create a virtual commit that will be used as the actual common ancestor for the three-way merge algorithm.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…