gpt4 book ai didi

git - 是否可以显示 git 分支是否具有相同的提交,如果其中一个分支已重新设置基址,因此它们没有相同的 SHA1 ID?

转载 作者:太空狗 更新时间:2023-10-29 13:41:14 25 4
gpt4 key购买 nike

我正在尝试获得与运行 git branch --merged 相同的效果,但允许相同的提交(提交消息 + diff)在某个时间点重新设置基数。

最佳答案

使用带有 --cherry-mark 选项的 git log 将起作用。具体来说,您可以看到一组在分支 A 和分支 B 之间相同的提交,具有以下内容:

git log --cherry-mark --oneline --graph --decorate A...B

示例输出:

$ git log --cherry-mark --oneline --graph --decorate master...feature
= 1e4f971 (HEAD, feature) Add some greetings
= 926857a Add some greetings
= bfede5b Add some greetings
= 14099b6 (master) Add some Hellos
= a0576fa Add some Hellos
= 8822553 Add some Hellos

在上面的输出中,您将看到 feature 输出中的前 3 次提交等同于 master 输出中的前 3 次提交,尽管sha ID 和提交消息不同。

来自official Linux Kernel Git documentation for git log :

--cherry-mark

Like --cherry-pick (see below) but mark equivalent commits with = rather than omitting them, and inequivalent ones with +.

--cherry-pick

Omit any commit that introduces the same change as another commit on the "other side" when the set of commits are limited with symmetric difference.

For example, if you have two branches, A and B, a usual way to list all commits on only one side of them is with --left-right (see the example below in the description of the --left-right option). It however shows the commits that were cherry-picked from the other branch (for example, "3rd on b" may be cherry-picked from branch A). With this option, such pairs of commits are excluded from the output.

您还可以在 Revision Selection chapter 了解更多关于三点 ... 提交范围语法的信息的 FREE online Pro Git book .

关于git - 是否可以显示 git 分支是否具有相同的提交,如果其中一个分支已重新设置基址,因此它们没有相同的 SHA1 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18324822/

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