简体   繁体   English

检查提交是否合并到另一个分支,如果是,那么合并提交是什么?

[英]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有两个分支, mastertest commitA is made on the test branch. commitA是在test分支上创建的。 I want to check: 我想查一下:

  1. Whether commitA has been merged to the master branch? commitA是否已合并到master分支?
  2. If so, what is the SHA of the merge commit? 如果是这样,合并提交的SHA是什么?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM