master
)创建的功能分支上工作时,我们可以使用以下 git 命令查看已添加到 feature
分支但未在 master
分支上的提交记录列表:git log --oneline master..HEAD
这会输出一个关于feature
分支上没有在master
分支上的提交的简短总结(请注意,此命令在检出feature
分支之后运行):
$ git log --oneline master..HEAD
1ca070a (HEAD -> feature) foo the bar
03a1047 baz the wuz
c9e8279 fop the sip
6ee6d6f up the ante
5812200 bop the binky
问题是,在
master
分支上它不显示共同的祖先提交记录。我希望这个命令能够包含一个额外的行,即共同的祖先提交记录,就像这样:1ca070a (HEAD -> feature) foo the bar
03a1047 baz the wuz
c9e8279 fop the sip
6ee6d6f up the ante
5812200 bop the binky
fb37d68 (master) fuzzy the wuzzy
我认为将master
替换为master~1
将包括共同祖先之前的一个提交,因此包括共同祖先。
git log --oneline master~1..HEAD
无论我指定master
还是master~1
,日志摘要总是相同的。
$ git log --oneline master~1..HEAD
1ca070a (HEAD -> feature) foo the bar
03a1047 baz the wuz
c9e8279 fop the sip
6ee6d6f up the ante
5812200 bop the binky
我的问题是,如何在日志摘要中包含共同的祖先提交?请注意,共同的祖先不一定是master
分支的末尾。
~1
可能已经实现了你想要的功能。(如果没有,那就意味着你已经将提交添加到了master
分支。)尝试使用git log --all --decorate --oneline --graph
命令来查看图形,以确定master~1
实际上是哪个提交,从而找出为什么master~1..HEAD
在这里失败了。同时,考虑使用--boundary
标志,但根据我的经验,这会选择太多的提交。 - torekmaster
的末尾,则只有使用master~1
才会显示祖先提交。(如果我将feature
分支变基到master
的末尾,则使用master~1
会按预期显示祖先提交。) - charlesreid1