有人可以帮我了解这里发生了什么吗?
我从 git log --oneline
开始,它吐出:
4df9421 (HEAD, master) moved some aliases around
d3810e4 (origin/master) some terminal color changes
a7182d3 git colors, ignores, etc.
995fe8c added gitconfig, moved some personal stuff out of the public repo
8a100b7 misc unimportant updates
55d2c08 added a fix to "open with", refactored
7ec7d83 Removed some vim colors; added a couple searching aliases
330c7fc Minor updates
44e80a1 Added vim files
48537c6 Fixed some formatting problems
14933a2 Initial Commit
然后我执行 git reset --hard 330c7fc
将日志返回到:
330c7fc (HEAD, master) Minor updates
44e80a1 Added vim files
48537c6 Fixed some formatting problems
14933a2 Initial Commit
到目前为止一切顺利,但是(现在我已经重置了)当我执行 git log --oneline --all
我得到:
d3810e4 (origin/master) some terminal color changes
a7182d3 git colors, ignores, etc.
995fe8c added gitconfig, moved some personal stuff out of the public repo
8a100b7 misc unimportant updates
55d2c08 added a fix to "open with", refactored
7ec7d83 Removed some vim colors; added a couple searching aliases
330c7fc (HEAD, master) Minor updates
44e80a1 Added vim files
48537c6 Fixed some formatting problems
14933a2 Initial Commit
请注意,最近的条目“4df9421 moves some aliases around”不在此列表中。
我的理解是 --all
选项应该显示所有提交。为什么在我恢复到较早的提交后最新的丢失了?
谢谢。
最佳答案
它丢失了,因为它不再被 HEAD 或分支引用。
您已使用 git reset --hard
将两者(HEAD 和 master)重置为另一个提交.
只有 git reflog
会告诉你最近的提交。
git log --all
仅用于列出 refs/
中引用的提交(比如标签、头像……)
--all
Pretend as if all the refs in
refs/
are listed on the command line as<commit>
.
关于git --all 缺少提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15426257/