How can I undo git reset --hard HEAD~1?

后端 未结 18 3142
逝去的感伤
逝去的感伤 2020-11-22 00:21

Is it possible to undo the changes caused by the following command? If so, how?

git reset --hard HEAD~1
18条回答
  •  面向向阳花
    2020-11-22 00:38

    Made a tiny script to make it slightly easier to find the commit one is looking for:

    git fsck --lost-found | grep commit | cut -d ' ' -f 3 | xargs -i git show \{\} | egrep '^commit |Date:'

    Yes, it can be made considerably prettier with awk or something like it, but it's simple and I just needed it. Might save someone else 30 seconds.

提交回复
热议问题