在一个分支 A 总是 merge 到另一个 B 的分支模型中,如何列出 B 中的所有提交而不是 A 中的所有提交,同时忽略所有精心挑选的提交和 merge ?
a1-------b2' -- A
/ \ \
b1--b2--m1--b3--m2--b4 -- B
b2': cherry-picked commit
在这种情况下,它应该列出提交 b3、b4
。
git手册中的一些研究:
git-log
的 --no-merges
和 --cherry-*
选项已经解决了忽略 merge 和精选提交的问题命令。但是 --cherry-*
使用提交对称差异(即 A...B
)将 cherry-picks 匹配在一起。在此示例中,提交 b2 不是其中的一部分。 git log --cherry A...B
返回 b2, b3, b4
。
你可以重现这个例子:
mkdir reprod; cd reprod; git init
git check-out -b B
git commit -m "b1" --allow-empty
git commit -m "b2" --allow-empty
git check-out -b A B^{/b1}
git commit -m "a1" --allow-empty
git cherry-pick --allow-empty B^{/b2}
git check-out B
git merge A^{/a1} --no-edit
git commit -m "b3" --allow-empty
git merge A^{/b2} --no-edit
git commit -m "b4" --allow-empty
git log A...B --cherry
最佳答案
(失败的假设 - 保留在这里仅供历史引用)
看来你必须在这里使用 --left-only
/--right-only
。
见此paragraph .
For example,
--cherry-pick --right-only A...B
omits those commits from B which are in A or are patch-equivalent to a commit in A. In other words, this lists the + commits fromgit cherry A B
. More precisely,--cherry-pick --right-only --no-merges
gives the exact list.
这不正是您的情况吗?
关于git - 列出与完全 merge 的分支的提交差异时如何忽略精心挑选的提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56798783/