$ git reflog show
93567ad HEAD@{0}: reset: moving to HEAD@{6}
203e84e HEAD@{1}: reset: moving to HEAD@{1}
9937a76 HEAD@{2}: reset: moving to HEAD@{2}
203e84e HEAD@{3}: checkout: moving from master to master
203e84e HEAD@{4}: reset: moving to HEAD~1
9937a76 HEAD@{5}: reset: moving to HEAD~1
d5bb59f HEAD@{6}: reset: moving to HEAD~1
9300f9d HEAD@{7}: commit: fix-bug
# said the commit to be recovered back is on 9300f9d (with commit message fix-bug)
$ git reset HEAD@{7}你的一天回来了!:)
我不小心跑了git reset --hard今天在我的回购上,今天也有未承诺的改变。为了把它拿回来,我跑了git fsck --lost-found,它将所有未引用的小块写入<path to repo>/.git/lost-found/..由于文件未提交,我在other目录中的<path to repo>/.git/lost-found/..从那里,我可以看到未提交的文件git show <filename>复制出这些气泡,并重新命名它们。注意:只有在将要保存的文件添加到索引中(使用git add .)。如果文件不在索引中,它们就会丢失。