不正确的手动合并冲突解决之后,重新合并合并 [英] Reconflict the merge, after incorrect manual merge conflict resolution

查看:376
本文介绍了不正确的手动合并冲突解决之后,重新合并合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在解决了合并冲突并提交之后,很明显我的手动合并冲突解决方法是错误的.我已经上演,承诺并推动了回购. 如何使有冲突的文件恢复为有冲突的状态,以便以其他方式解决它?

After resolving a merge conflict and committing, it has become apparent that my manual merge conflict resolution was wrong. I have already staged, committed, and pushed the repo. How can I get the conflicting file back into the conflicting state, such that I might resolve it differently?

请注意,对于git checkout -m,为时已晚,因为我已经提交了错误的合并分辨率.

Note that it is too late for git checkout -m as I've already committed the incorrect merge resolution.

推荐答案

从干净的工作目录开始,我将在合并之前硬重置回,开始新的分支,然后再次执行合并.然后,您可以在原始合并结果分支与新分支之间进行比较,以获取要应用于原始分支的补丁文件.由于已经推送了结果,因此您将需要创建一个新的提交来更正合并提交,而不是在编辑历史记录后执行强制推送.

Starting from a clean working directory, I would hard reset back to before the merge, start a new branch, and perform the merge again. You could then perform a diff between the original merge result branch and your new branch to get a patch file to apply on the original branch. Since you have already pushed your result, you will want to create a new commit correcting the merge commit rather then performing a force push after editing the history.

过于详细的版本:

如果您当前的历史记录看起来像这样,并且c是您要更改的合并提交.

If your current history looks something like this and c is the merge commit you want to change.

a - c - d <-HEAD/master
   /  
  b

完全 干净的工作目录开始.

Starting from a completely clean working directory.

git branch old_merge <sha1 of c>  // create branch for original merge
git checkout -b new_merge <sha1 of a> // create and checkout branch before merge
// re-merge branch

这将创建类似这样的内容...

This will create something like this...

 old_merge
    ∨
a - c - d <-master
  X  
b - c' <-HEAD
    ∧
 new_merge

这可能确实令人困惑,但希望您能理解.现在,您可以在old_merge分支和new_merge分支之间执行比较,以获取您需要在master上进行的更改.

That's probably really confusing but hopefully you get the idea. Now you can perform a diff between the old_merge branch and the new_merge branch to get the changes you will need to make on master.

git diff old_merge..new_merge

再次检出master后,可以使用UNIX实用程序patch来应用两个分支之间的差异.

You could use the patch UNIX utility to apply the difference between the two branches after you have checked out master again.

git checkout master
git diff old_merge..new_merge | patch -p1

希望这会有所帮助.让我知道您是否有任何困惑.

Hopefully this helps. Let me know if you are confused by anything.

这篇关于不正确的手动合并冲突解决之后,重新合并合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆