How to undo 'git reset'?

前端 未结 5 1043
予麋鹿
予麋鹿 2020-11-22 09:17

What\'s the simplest way to undo the

git reset HEAD~

command? Currently, the only way I can think of is doing a \"git clone http://...\" fr

5条回答
  •  孤独总比滥情好
    2020-11-22 10:10

    My situation was slightly different, I did git reset HEAD~ three times.

    To undo it I had to do

    git reset HEAD@{3}
    

    so you should be able to do

    git reset HEAD@{N}
    

    But if you have done git reset using

    git reset HEAD~3
    

    you will need to do

    git reset HEAD@{1}
    

    {N} represents the number of operations in reflog, as Mark pointed out in the comments.

提交回复
热议问题