在git中找到所有未提交的提交? [英] find all unreferred commit in git?
问题描述
我怀疑我执行了最后一次提交(B)的错误修正(B'),这导致我在上次提交(B)中的所有工作都没有了。
I suspect I have performed an incorrect amendment (B') of last commit (B), which cause all my work in the last commit (B) gone.
A
|
B [master]
amend to
A
/ |
B B'
[master]
我想如果我没有做任何git gc,我原来的正确提交(B)仍然应该在存储库中。但是,因为它不是被任何裁判直接/间接地提及,所以我找不到它。有没有什么办法可以在git中列出这样的未提交提交,以便我可以从该提交中检索我的工作?
I think if I haven't do any git gc, my original "correct" commit (B) should still in the repository. However, because it is not referred directly/indirectly by any ref, I cannot find it out. Is there any way that I can list out such kind of "unreferred" commit in git so that I can retrieve my work from that commit?
谢谢
推荐答案
是的, reflog 是你正在寻找的。每次分支HEAD更改时,reflog都会记录分支的前一个值。
Yes, the reflog is what you're looking for. The reflog keeps a record of the previous value of a branch every time the branch HEAD changes.
这篇关于在git中找到所有未提交的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!