Recover from git reset --hard?

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

     git reset HEAD@{4}
    

    4 is changes before 4 steps ago. if you select a correct step, it should show the list of files that you removed from hard. then do:

    $ git reflog show
    

    it's going to show you local commit history we've already created. now do:

    $ git reset --hard 8c4d112
    

    8c4d112 is a code you want to reset your hard there. let's look at https://www.theserverside.com/video/How-to-use-the-git-reset-hard-command-to-change-a-commit-history to get more information.

提交回复
热议问题