Is there any way to undo the effects of “git revert head”?

前端 未结 4 1535
萌比男神i
萌比男神i 2020-12-02 16:17

I\'ve accidentally run the command against the wrong branch in my repository - is there a way to undo this change?

4条回答
  •  旧巷少年郎
    2020-12-02 17:20

    The command git revert just creates a commit that undoes another. You should be able to run git revert HEAD again and it'll undo your previous undo and add another commit for that. Or you could do git reset --hard HEAD~. But be careful with that last one as it erases data.

    HEAD~ means the commit before the current HEAD

提交回复
热议问题