如何查看合并到合并提交中的提交? [英] How to see commits that were merged in to a merge commit?

查看:20
本文介绍了如何查看合并到合并提交中的提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果my-feature-branch合并到my-main-branch,我如何才能看到my-feature-branch中合并了哪些提交?

推荐答案

如果要查看上次合并中合并的每个提交,可以尝试:

git log $(git merge-base --octopus 
$(git log -1 --merges --pretty=format:%P)).. --boundary

以下是我当前日志的一个示例:

$ git log --graph --pretty=oneline --abbrev-commit
* 44899b9 pouf
*   8f49f9c Merge branch 'test'
|  
| * 3db39ca test
* | 69f431c pif
* | df1f51c lala
|/  
* 8fae178 pif2
* 20f8ba6 init

如果我只想要与最后一个合并相关的提交,我必须使用git log -1 --merges --pretty=format:%P,这为我提供了第一个可用的合并的父级:

$ git log -1 --merges --pretty=format:%P
69f431cec7859b61d33c7503c9431ceea2aaf3e0 3db39ca3ab1e8f70462db23d94590628b5e7ad7b

现在我知道了需要跟踪哪些父母,我需要通过git merge-base --octopus(--octopus在那里以防万一)获得他们的共同库:

$ git merge-base --octopus 
$(git log -1 --merges 
--pretty=format:%P)
8fae178666e34a480b22e40f858efd9e7c66c3ca

现在使用git log我可以搜索从基数到当前HEAD的每个提交:

$ git log $(git merge-base --octopus 
$(git log -1 --merges --pretty=format:%P)).. 
--boundary --graph --pretty=oneline --abbrev-commit 
* 44899b9 pouf
*   8f49f9c Merge branch 'test'
|  
| * 3db39ca test
* | 69f431c pif
* | df1f51c lala
|/  
o 8fae178 pif2

如果你是个完美主义者,你也可以这么做:

$ git log 
$(git merge-base --octopus 
$(git log -1 
--merges --pretty=format:%P))..$(git log -1 --merges --pretty=format:%H) 
--boundary --graph --pretty=oneline --abbrev-commit 
*   8f49f9c Merge branch 'test'
|  
| * 3db39ca test
* | 69f431c pif
* | df1f51c lala
|/  
o 8fae178 pif2

现在我想我会将其保留为别名:)

--graph --pretty=oneline --abbrev-commit选项是可选的。


资源:

这篇关于如何查看合并到合并提交中的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆