How to recover after i execute :git reset --hard HEAD

后端 未结 6 804
梦如初夏
梦如初夏 2020-12-31 11:37

I made a terrible mistake and execute \"git reset --hard HEAD\", all day\'s the local modification lost, how can i recover it?

Thanks millions

6条回答
  •  余生分开走
    2020-12-31 12:21

    First run:

    git reflog
    

    It will show history of your HEAD pointer. Then select sha-code of a necessary state from first column. I think it will be near HEAD@{1} if you made just git reset --hard once. And then

    git merge SHA_CODE
    

    Bingo!

    More examples you can find here: http://www.programblings.com/2008/06/07/the-illustrated-guide-to-recovering-lost-commits-with-git/

提交回复
热议问题