Undo a Git merge that hasn't been pushed yet

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

    If you want a command-line solution, I suggest to just go with MBO's answer.

    If you're a newbie, you might like the graphical approach:

    1. Kick off gitk (from the command line, or right click in file browser if you have that)
    2. You can easily spot the merge commit there - the first node from the top with two parents
    3. Follow the link to the first/left parent (the one on your current branch before the merge, usually red for me)
    4. On the selected commit, right-click "Reset branch to here", pick the hard reset there

提交回复
热议问题