显示涉及先前的git合并的提交 [英] Show commits involved in a prior git merge

查看:106
本文介绍了显示涉及先前的git合并的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我从开发分支创建了一个修补程序分支,进行两次提交,将其合并回到开发分支,并销毁修补程序分支。

我如何知道哪些提交是合并的一部分?这可能吗?

解决方案

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

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

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

  $ git log --graph --pretty = oneline --abbrev-commit 
* 44899b9 pouf
* 8f49f9c合并分支测试'
| \
| * 3db39ca测试
* | 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和voilà的每个提交:

>

  $ git log $(git merge-base --octopus $(git log -1 --merges --p retty = format:%P)).. --boundary --graph --pretty = oneline --abbrev-commit 
* 44899b9 pouf
* 8f49f9c合并分支'test'
| \\ \\
| * 3db39ca测试
* | 69f431c pif
* | df1f51c lala
| /
o 8fae178 pif2

如果你有点完美主义者你也可以这样做:

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

现在我想我会保持这是一个别名:)



PS:显然你不必保留 - graph --pretty = oneline --abbrev-提交选项






资源:




Say I create a hotfix branch off of a develop branch, make two commits, merge this back to the develop branch, and destroy the hotfix branch.

How do I find out what commits were part of the merge? Is that possible?

解决方案

If you want to see every commits merged in the last merge you can try that :

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

Here is an example of my current log :

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

If I only want commits related to the last merge I have to use git log -1 --merges --pretty=format:%P which gives me the parents of the first merge available :

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

Now that I know which parents I need to track, I need their common base that I can obtain through git merge-base --octopus (--octopus is there just in case) :

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

Now with git log I can search every commit since the base to the current HEAD and voilà :

$ 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

If you're a bit perfectionist you can also do this :

$ 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

Now I think I'll keep this as an alias :)

PS: Obviously you don't have to keep the --graph --pretty=oneline --abbrev-commit options


Resources :

这篇关于显示涉及先前的git合并的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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