简体   繁体   English

在Git中合并后无法还原

[英]Cannot revert after merge in Git

This is my situation. 这是我的情况。 I'm working on the MiniMaxAB branch (green line) 我正在MiniMaxAB分支(绿线)上工作

在此处输入图片说明

I accidentally merged a branch (purple) into mine (green) and pushed it. 我不小心将一个分支(紫色)合并到我的(绿色)中,然后将其推入。 Which is stupid (i just started learning git) and bad for our goal. 这是愚蠢的(我刚刚开始学习git),对我们的目标不利。 Now i would love to revert this and undo this merge. 现在,我想还原此合并并撤消此合并。 Therefore i picked up the hash of the latest commit in the green branch before the merge (which is not visible in this chart because 15days old) and tried to revert: 因此,我在合并之前在绿色分支中获取了最新提交的哈希(由于15天的历史,该图表中未显示该哈希)并尝试还原:

git revert 86ed202152e719ae719654f7805bd2991f63fd29

Unfortunately it doesn't work... This is what git says: 不幸的是,它不起作用...这就是git所说的:

在此处输入图片说明

So i tried with reset, which works 所以我尝试了重置,这有效

git reset 86ed202152e719ae719654f7805bd2991f63fd29

But when i push, i get this error: 但是当我推送时,出现此错误:

在此处输入图片说明

How can i fix it? 我该如何解决?

You should follow the steps below: 您应该按照以下步骤操作:

Step 1: Manually merge your conflict file minmax_ab_engine.e and ticktactoe.e (Open those files and edit them) 步骤1:手动合并冲突文件minmax_ab_engine.eticktactoe.e (打开这些文件并进行编辑)

Step 2: Add to stage by git add -A 第2步:通过git add -A添加到舞台

Step 3: Commit those files by git commit -m 'merge conflict files 步骤3:通过git commit -m 'merge conflict files提交这些git commit -m 'merge conflict files

Step 4: Pull the update from the remote by git pull origin MiniMaxAb 步骤4:通过git pull origin MiniMaxAb从远程获取更新

Step 5: Push your update to remote git push origin MiniMaxAb 步骤5:将更新推送到远程git push origin MiniMaxAb

In case you want to revert, you can bypass step 4,5 如果要还原,可以绕过步骤4,5

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

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