2

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]

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

Adrian Shum
  • 38,812
  • 10
  • 83
  • 131

1 Answers1

3

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.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • 2
    If you've managed to get to where the commit isn't even in the reflog anymore, there's still hope - it's a job for `git fsck`, which can list dangling objects! – Cascabel Aug 31 '10 at 13:00