Recover from git reset --hard?

后端 未结 22 2807
盖世英雄少女心
盖世英雄少女心 2020-11-22 00:52

Is there any way to recover uncommitted changes to the working directory from a git reset --hard HEAD?

22条回答
  •  没有蜡笔的小新
    2020-11-22 01:36

    Correct answers. OK, now I like git. :-) Here's a simpler recipe.

    git log HEAD@{2}
    git reset --hard  HEAD@{2}
    

    Where "2" is the number of back to where you committed your changes. In my case, interrupted by colleague and boss to help debug some build issue; so, did a reset --hard twice; so, HEAD and HEAD@{1} were over-writes. Whew, would have lost an our of hard work.

提交回复
热议问题