简体   繁体   English

Git - 撤消将主分支合并到另一个分支

[英]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.前几天我在一个 GitHub 项目上做一些提交工作时犯了一个错误。 I am still a little new to git (an undergrad student) and I need to undo a merge.我对 git (本科生)还有些陌生,我需要撤消合并。 I accidentally merged the master branch, as seen in the photo below, to the feature branch called 'wav2sig-scal-RMS-vals'.我不小心将主分支(如下图所示)合并到名为“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. image我已经查看了几个关于如何解决这种情况的指南,但我无法弄清楚。 Here is what git reflog returns:这是 git reflog 返回的内容:

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.使用提交的主题标签或 HEAD~ 作为还原的目标。

look here on how to do a revert.在这里查看如何进行还原。

  1. git reflog (find the Head of the last git/commit) git reflog (找到最后一个 git/commit 的 Head)
  2. git reset --merge 796bf9aee (Head of the last git/commit where you want to reset) git reset --merge 796bf9aee (您要重置的最后一个 git/commit 的负责人)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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