Undo a Git merge that hasn't been pushed yet

前端 未结 30 2158
情歌与酒
情歌与酒 2020-11-21 22:27

Within my master branch, I did a git merge some-other-branch locally, but never pushed the changes to origin master. I didn\'t mean to merge, so I\'d like to un

30条回答
  •  一生所求
    2020-11-21 23:14

    You can use only two commands to revert a merge or restart by a specific commit:

    1. git reset --hard commitHash (you should use the commit that you want to restart, eg. 44a587491e32eafa1638aca7738)
    2. git push origin HEAD --force (Sending the new local master branch to origin/master)

    Good luck and go ahead!

提交回复
热议问题