[英]Check if a commit is merged to another branch, and if so, what is the merge commit?
Suppose a git repo has two branches, master
and test
. 假设一个git repo有两个分支, master
和test
。 commitA
is made on the test
branch. commitA
是在test
分支上创建的。 I want to check: 我想查一下:
commitA
has been merged to the master
branch? commitA
是否已合并到master
分支? I want to check these programmatically (not by using gitk
). 我想以编程方式检查这些(不是通过使用gitk
)。
There's a tool called git-when-merged
that was designed exactly for this use-case. 有一个名为git-when-merged
的工具,专为此用例设计。 After installing it, 安装后,
git when-merged commitA master
should do the trick. 应该做的伎俩。
By your example, the branch test
is now at commit commitA
. 通过您的示例,分支test
现在位于commit commitA
。 So you can check where commitA
has been merged into master
by this command: 因此,您可以通过以下命令检查commitA
已合并到master
的位置:
git branch --contains test
This should list all branches that contains commitA
, check to see if master
is in the list. 这应该列出包含commitA
所有分支,检查master
是否在列表中。
For getting the SHA of commitA
type: 要获取commitA
类型的SHA:
git rev-parse test
The SHA of the merge commit and the commitA
itself are the same. 合并提交的SHA和commitA
本身是相同的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.