如果你想结账
7a162e3 Merged in branch1 (pull request #223)
:
-
最简单、明确的方法就是跑步
git checkout 7a162e3
(你有sha,使用它)
-
如果你跑了
git log --oneline --graph -n 5
,你可能会看到:
3ad352f * (HEAD -> develop, origin/develop, asdf) commit message
93eeda7 * Merged in branch (pull request #224)
|\
911eb78 | * (origin/sdfa, asdf) Removes txt file
4b9de92 | * branch1
7a162e3 * Merged in branch1 (pull request #223)
(
笔记
:从您问题中的提交消息中,我不确定我是否了解您的回购的正确历史记录,请在您的终端中检查您的提交是如何关联的)
如果历史记录如上所述,从活动提交中计算“第一个父母”,那么您会计算
HEAD~2
(而不是
HEAD~5
)
<commit>~N
只会遵循从
<commit>
虽然
git log
或
git log --oneline
如果没有其他选项,将列出(在平面列表中)来自合并分支的提交,这将“添加”到显示的提交计数中。
git日志
或
git rev-list
两者都有各自的特点
--first-parent
选项,还可以将显示的提交列表限制为该“第一个父项”序列:
git log --oneline --first-parent HEAD~5..HEAD # will list only 5 commits
git rev-list --count --first-parent HEAD~5..HEAD # will display '5'
我还强烈建议滥用
--graph
选择
git日志
,以了解您看到的提交是如何相互依赖的:
git log --oneline --graph # you will have a view of what commits are merges,
# and what commits come from side branches
附加说明
自从
HEAD
(相当于
HEAD~0
)显示在
git日志
的输出中,还存在“关闭一个”错误
-n 5
:在显示的列表中
git log -n 5
,你最多会看到
HEAD~4
不
头~5
.