开发者

find all unreferred commit in git?

开发者 https://www.devze.com 2023-01-14 10:28 出处:网络
I suspect I have performed an incorrect amendment (B\') of last commit (B), which cause all my work in the开发者_Go百科 last commit (B) gone.

I suspect I have performed an incorrect amendment (B') of last commit (B), which cause all my work in the开发者_Go百科 last commit (B) gone.

  A
  |
  B [master]

amend to 
     A
   / |
  B  B'
    [master]

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?

Thanks


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消