【发布时间】:2013-09-28 20:41:29
【问题描述】:
比较What are the differences between double-dot ".." and triple-dot "..." in Git commit ranges?,这是一个更常见的有用问题。
我想澄清以下是否产生与git log A..B 相同的提交集:
# version 1
git log --right-only A...B
# version 2
#
# (The sed part keeps only the righthand lines, and strips the > character)
git log --left-right --format=oneline A...B | sed -n "s/^>//p"
他们会似乎以更迂回的方式来完成同样的事情。
最初的动机是更深入地理解这些命令的含义,其中涉及忽略已经挑选的提交:
# version 1a
#
# Literally taken from the git-log help page, which explains what this means
git log --cherry-pick --right-only A...B
# version 2a
#
# This is a simplified version of something in the git code. (In particular,
# in git-rebase--interactive.sh.)
git log --left-right --cherry-pick --no-merges --format=oneline A...B | sed -n "s/^>//p"
这个问题的延伸是问为什么需要对称差异(即三点)来进行这种“单面”的樱桃选择消除。例如,要找到 B 上的唯一提交,包括对樱桃挑选的更正,难道不应该做一些像
这样简单的事情吗?git log --cherry-pick A..B
我想这是因为 git 在 之后应用了去除樱桃的逻辑,它用A..B 过滤掉了所有 A 提交。 (也就是说,在这个假设的命令中,git 在尝试应用挑选逻辑之前会丢弃与 A 相关的所有内容。)
【问题讨论】:
标签: git git-log git-cherry-pick git-rev-list