git log 当 HEAD 落后于提示时?

Reb*_*bin 0 git git-log

假设 HEAD 位于 master 的最终提交处,日志如下所示

$ git log --oneline
bcaee1c 15 July update
02ff17a add feature x
0910b6f end of weekly update
c2b7189 add 03 july update
737be94 add feature y
Run Code Online (Sandbox Code Playgroud)

现在我想回顾一下过去:

$ git checkout 0910b6f
Run Code Online (Sandbox Code Playgroud)

现在日志没有显示最近状态的任何提示——来自 HEAD 的相对未来

$ git log --oneline

0910b6f end of weekly update
c2b7189 add 03 july update
737be94 add feature y
Run Code Online (Sandbox Code Playgroud)

好吧,没问题,我只是“记住”或“写下”最远的提交,bcaee1c然后我可以返回git checkout bcaee1c,但是 BAMMO,来了一个电话,一堆紧急会议,强制重启,周末,我“忘记”和/或丢失了便利贴。我(很久)回来后,所有的精神背景都被破坏了,并开始创作,后来才发现我搞砸了,并且有一份重置、恢复和倒带的取证工作。

我可以git log展示 的未来HEAD吗?对于这种情况,有更好的 git-fu 吗?

小智 5

要显示所有提交、分支、标记,您可以在文件~/.gitconfig中添加此行

tree = log --graph --decorate --pretty=oneline --abbrev-commit --all
Run Code Online (Sandbox Code Playgroud)

您可以使用以下命令运行它: git tree