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

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

    It is possible to recover it if Git hasn't garbage collected yet.

    Get an overview of dangling commits with fsck:

    $ git fsck --lost-found
    dangling commit b72e67a9bb3f1fc1b64528bcce031af4f0d6fcbf
    

    Recover the dangling commit with rebase:

    $ git rebase b72e67a9bb3f1fc1b64528bcce031af4f0d6fcbf
    

提交回复
热议问题