微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

GIT:查找修补程序分支的连接点

如何解决GIT:查找修补程序分支的连接点

我正在寻找一种方法来查找2个以上分支的最新共同祖先提交,以找到修补程序分支的理想结点。
关于“补丁分支”,我的意思是:https://devblogs.microsoft.com/oldnewthing/20180314-00/?p=98235

我为此找到了2个命令:

git show-branch --merge-base branch1 branch2 ... branchN
git merge-base --octopus branch1 branch2 ... branchN

它们之间有什么区别

文档说:

https://git-scm.com/docs/git-show-branch#Documentation/git-show-branch.txt---merge-base

-合并基础
显示指定的提交确定可能的合并基础,而不是显示提交列表。所有合并基础将包含在所有指定的提交中。这与git-merge-base [1]处理三个或更多提交的情况不同。

https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---octopus

-章鱼
计算所有提供的提交中最好的共同祖先,以准备进行n次合并。这模仿了git show-branch --merge-base的行为。

git show-branch --merge-basegit merge-base --octopus做的完全一样吗?
哪个命令可以安全找到修补程序分支的连接点?

解决方法

git show-branch --merge-basegit merge-base的不同之处在于,使用git show-branch时,所有合并基础都将包含在所有指定的提交中。

--merge-base
Instead of showing the commit list,determine possible merge bases for the specified 
commits. All merge bases will be contained in all specified commits. This is different 
from how git-merge-base[1] handles the case of three or more commits.

https://git-scm.com/docs/git-show-branch

如果指定了两个以上与git merge-base方法不同的提交,则香草git show-branch给出的合并基础不一定包含在每个提交参数中。但是,如果将--octopus作为参数提供,则确实可以模仿git show-branch --merge-base的行为。

所以这两个命令应该提供相同的输出。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。