Undo a Git merge that hasn't been pushed yet

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

    Got to this question also looking to revert to match origin (ie, NO commits ahead of origin). Researching further, found there's a reset command for exactly that:

    git reset --hard @{u}

    Note: @{u} is shorthand for origin/master. (And, of course, you need that remote repository for this to work.)

提交回复
热议问题