Undo a Git merge that hasn't been pushed yet

前端 未结 30 2207
情歌与酒
情歌与酒 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:17

    See chapter 4 in the Git book and the original post by Linus Torvalds.

    To undo a merge that was already pushed:

    git revert -m 1 commit_hash
    

    Be sure to revert the revert if you're committing the branch again, like Linus said.

提交回复
热议问题