简体   繁体   中英

Git - Undo merging master branch into another branch

I made a mistake the other day when doing some commits on a GitHub project for work. I am still a little new to git (an undergrad student) and I need to undo a merge. I accidentally merged the master branch, as seen in the photo below, to the feature branch called 'wav2sig-scal-RMS-vals'. image I've looked at several guides on how to remedy a situation like this, but I can't figure it out. Here is what git reflog returns:

git reflog
9fb9307 HEAD@{0}: undo: checkout: moving from master to wav2sig-scale-RMS-vals
9c3d141 HEAD@{1}: undo: commit: Revert "Merge branch 'master' into wav2sig-scale-RMS-vals"
6933c35 HEAD@{2}: commit: Revert "Merge branch 'master' into wav2sig-scale-RMS-vals"
9c3d141 HEAD@{3}: checkout: moving from master to wav2sig-scale-RMS-vals
9fb9307 HEAD@{4}: clone: from https://github.com/UKY-Distributed-Audio-Lab/Array-Toolbox.git

Any ideas for how to fix this problem? I know it should be simple. Thanks.

A merge is translated into a commit. All you need to do is to revert to the commit that preceded the merge. use the hashtag of the commit or the HEAD~ as a target for the revert.

look here on how to do a revert.

  1. git reflog (find the Head of the last git/commit)
  2. git reset --merge 796bf9aee (Head of the last git/commit where you want to reset)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM