gpt4 book ai didi

git - git cherry 和 git log --cherry 命令之间的区别

转载 作者:行者123 更新时间:2023-12-04 14:26:12 24 4
gpt4 key购买 nike

git cherry 开发功能/ABC
- 1014d04c60efccb5d0b8762af1371831bb234b17

git cherry 命令正确显示提交 1014d04(标记为 -)可以在针对开发的 rebase 过程中从功能分支中删除。因为它已经被精心挑选来开发。

但是 git log cherry 命令似乎不起作用(用 + 标记)

git log --cherry --oneline develop..feature/ABC
+ 1014d04 添加一些评论

git log --cherry-mark --oneline develop..feature/ABC
+ 1014d04 添加一些评论

我在

git --version
git 版本 2.12.0.windows.1

最佳答案

--cherry-mark--cherry 选项实际上要求您进行对称差分。这从 --cherry 的描述中看得更清楚:

--cherry

    A synonym for --right-only --cherry-mark --no-merges; useful to limit the output to the commits on our side and mark those that have been applied to the other side of a forked history with git log --cherry upstream...mybranch, similar to git cherry upstream mybranch.

注意这里的三个点,它们调用了对称差分代码。这需要在任一分支上的提交,但不在两个分支上的提交,即,它排除了它们的 merge 基础和任何祖先提交。因此,选定的提交必须只能从左侧的 ID(在本例中为 upstream)或右侧的 ID (mybranch) 访问,但不能同时访问两者。 --left-right 选项会将每个提交标记为哪个“腿”到达它,而 --right-only 丢弃选定的左侧提交,但仅 等效提交被标记之后。

(可以使用 --cherry-mark 而不使用 --left-only--right-only ,但我认为它没那么有用:你无法分辨提交来自哪一侧。将 --cherry-mark--left-right 混合用左/右标记 (!) 替换樱桃标记。)

关于git - git cherry 和 git log --cherry 命令之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42932113/

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