Recover from git reset --hard?

后端 未结 22 2540
盖世英雄少女心
盖世英雄少女心 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:44

    This is what I usually do if I lose some changes.

    git reflog
    git checkout  // now you are in where you want but you cannot push from detached branch to master
    manually copy and paste changes from detached branch to master or working branch
    git reset --hard HEAD // if needed
    git add ... > git commit ... > git push ...
    

    to move the pointer back to your previous commits but keeping the changes you made so far in your latest commits checkout git reset --soft dadada

提交回复
热议问题