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

后端 未结 18 3128
逝去的感伤
逝去的感伤 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:40

    What you want to do is to specify the sha1 of the commit you want to restore to. You can get the sha1 by examining the reflog (git reflog) and then doing

    git reset --hard

    But don't wait too long... after a few weeks git will eventually see that commit as unreferenced and delete all the blobs.

提交回复
热议问题