查找包含特定提交的合并提交 [英] Find merge commit which include a specific commit
问题描述
c --- e --- g ---特征
/ \
-a --- b --- d --- f --- h ---主人
如何找到何时提交c已合并到master(即,查找合并提交h)?
您的示例显示分支功能
仍然可用。
在这种情况下 h
是最后一个结果:
git log master ^祖先路径
如果分支 feature
不再可用,您可以在 c
和 master 之间的历史记录行中显示合并提交。 code>:
git log< SHA-1_for_c> .. master --ancestry-path --merges
然而,这也会显示 h $ c之后发生的所有合并$ c>之间以及
e
和 g
之间 feature
。
比较以下命令的结果:
git rev-list< SHA-1_for_c> .. master --ancestry-path
git rev- list< SHA-1_for_c> .. master --first-parent
会给你SHA- 1的 h
作为共同的最后一行。
如果你有这个结果,你可以在这些结果中使用 comm -1 -2
。如果您使用的是msysgit,您可以使用以下perl代码进行比较:
perl -ne'print if($ seen { $ _}。= @ARGV)=〜/ 10 $ /'file1 file2
http://www.cyberciti.biz/faq/命令到显示行通常在文件/ ,它从在comp.unix.shell新闻组的人)。
如果您想将其作为一行代码,请参见流程替代。
Imagine the following history:
c---e---g--- feature
/ \
-a---b---d---f---h--- master
How can I find when commit "c" has been merged into master (ie, find merge commit "h") ?
Your example shows that the branch feature
is still available.
In that case h
is the last result of:
git log master ^feature --ancestry-path
If the branch feature
is not available anymore, you can show the merge commits in the history line between c
and master
:
git log <SHA-1_for_c>..master --ancestry-path --merges
This will however also show all the merges that happened after h
, and between e
and g
on feature
.
Comparing the result of the following commands:
git rev-list <SHA-1_for_c>..master --ancestry-path
git rev-list <SHA-1_for_c>..master --first-parent
will give you the SHA-1 of h
as the last row in common.
If you have it available, you can use comm -1 -2
on these results. If you are on msysgit, you can use the following perl code to compare:
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' file1 file2
(perl code from http://www.cyberciti.biz/faq/command-to-display-lines-common-in-files/ , which took it from "someone at comp.unix.shell news group").
See process substitution if you want to make it a one-liner.
这篇关于查找包含特定提交的合并提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!