gpt4 book ai didi

git - 查看 merge 提交的补丁

转载 作者:行者123 更新时间:2023-12-01 11:37:03 28 4
gpt4 key购买 nike

运行 git log --first-parent -p向我展示了我感兴趣的提交,但我想查看 merge 提交和非 merge 提交的补丁(-p 只显示非 merge 提交的补丁)。

有没有办法查看 merge 提交的补丁?

最佳答案

有很多选项可以控制这一点。

比较 merge 提交的基本问题是有多个父项(根据定义,因为它是 merge )。什么 git show (我知道,这不是 git log ,请稍等)默认情况下会向您显示“组合差异”,这在另一个不同的文档页面中进行了正确描述,用于 git diff-tree :

-c

This flag changes the way a merge commit is displayed (which means it is useful only when the command is given one tree-ish, or --stdin). It shows the differences from each of the parents to the merge result simultaneously instead of showing pairwise diff between a parent and the result one at a time (which is what the -m option does). Furthermore, it lists only files which were modified from all parents.

--cc

This flag changes the way a merge commit patch is displayed, in a similar way to the -c option. It implies the -c and -p options and further compresses the patch output by omitting uninteresting hunks whose the contents in the parents have only two variants and the merge result picks one of them without modification. When all hunks are uninteresting, the commit itself and the commit log message is not shown, just like in any other “empty diff” case.



我们现在准备一路跳到 git log ,它实现了所有三个选项( -c--cc-m ;注意 --cc 使用两个 - 字符,而其他只使用一个)。添加其中之一将为 merge 提交生成补丁。具体来说,您可能想要 -m .这实际上在 documentation 中有描述(接近网页末尾):

git log -p -m --first-parent

Shows the history including change diffs, but only from the “main branch” perspective, skipping commits that come from merged branches, and showing full diffs of changes introduced by the merges. This makes sense only when following a strict policy of merging all topic branches when staying on a single integration branch.

关于git - 查看 merge 提交的补丁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25776227/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com