git-merge-base只返回一个提交 [英] git-merge-base returns only one commit
问题描述
<<<<<<<<<临时合并分支x
blocks。 我中止合并,然后执行 git merge-base< source-犯> < target-commit>
,但它只返回一个SHA1。
是否有可能找出多个基本提交? / p>
您希望 - 全部
选项为 GIT中合并基
。从文档中:
-a,--all
输出提交的所有合并基数,而不是一个。
这将显示将用于创建临时树的所有合并基础作为递归合并基础。
例如,考虑一些交叉合并的分支'A'和'B':
<$
$ \\ c $ c> 3a4f5a6 - 973b703 - a34e5a1(分行A)
/ \ /
7c7bf85 X
\ / \
8f35f30 - - 3fd4180 - 723181f(branch B)
显然,分支A和B有两个共同的祖先,参与了一个纵横交错的合并: 3a3f5a6
和 8f35f30
。 git-merge-base
会选择一个共同的祖先作为合并基础,但是使用 - all
标志将包括:
%git-merge-base AB
3a3f5a6ec1c968d1d2d5d20dee0d161a4351f279
%git-merge-base --all AB
3a3f5a6ec1c968d1d2d5d20dee0d161a4351f279
8f35f30bfe09513f96cf8aa4df0834ae34e93bae
在这种情况下,正如你注意到的那样, git-merge-recursive
会合并两个合并库来创建一个虚拟提交,这个虚拟提交将被用作三维实体的实际共同祖先,双向合并算法。
When I merge between branches, git does a recursive merge with conflicts, putting in <<<<<<< Temporary merge branch x
blocks.
I abort the merge, and then do git merge-base <source-commit> <target-commit>
, but it returns only one SHA1.
Is it possible to find out what the multiple base commits are?
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.
这篇关于git-merge-base只返回一个提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!