Undo a git reset

This question already has an answer here:

  • How to move HEAD back to a previous location? (Detached head) 3 answers
  • How can I undo git reset --hard HEAD~1? 13 answers
  • Recover from git reset --hard? 15 answers

  • If you committed it, nothing is lost.

    If you have the reference of the commit, you can just git reset --hard <sha> to that precise commit.

    In case you don't you can always use git reflog to retrieve the sha before performing the hard reset.

    For instance if git reset --hard origin/master is the last command you run, you can do

    git reset HEAD@{1}
    
    链接地址: http://www.djcxy.com/p/18806.html

    上一篇: GitHub:回到以前的版本并分支它

    下一篇: 撤消git重置