如何恢复使用战略=我们的合并? [英] How to revert a merge which used strategy=ours?

查看:132
本文介绍了如何恢复使用战略=我们的合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个数据库,在数据库中几个星期前我们发现使用了 - strategy = ours 标志(它应该使用 - -strategy-option =我们的旗帜),因此不会对HEAD应用任何改变。但是,我们需要应用这些更改。 Git已经将分支识别为合并分支和历史分支中的提交。

I'm working with a repository where a merge was performed weeks ago which we just discovered used the --strategy=ours flag (it was supposed to use the --strategy-option=ours flag), thus not applying any changes to HEAD. However, we need to have the changes applied. Git already recognizes the branch as being merged and the commits in the history of the branch.

这种合并不能使用 git来恢复revert -m ...

恢复和/或重新应用合并以更改文件的正确方法是什么? / p>

What would be the proper way of reverting and/or re-applying the merge to change the files?

master  A - B - E - F - G ---> L - M - N
             \     /
topic         C - D

合并在这种情况下,提交(F)将是罪魁祸首。

Merge commit (F) would be the culprit in this scenario.

推荐答案

我发现了这个问题的解决方案。 Linus写的关于恢复错误合并的全部内容:如何恢复错误的合并
我们的案例中的 git merge --strategy =我们的主题并不打算。即使它是一个错误的合并,它不能被恢复,并且长期被推,具有恢复合并提交而不能恢复恢复提交的效果。

I have discovered a solution to this problem. It was all in the letter that Linus wrote regarding reverting faulty merges: How to revert a faulty merge. The git merge --strategy=ours topic in our case was not intended. Even though it's a faulty merge, it can't be reverted, and having long been pushed, has the same effect of having a revert merge commit without being able to revert the revert commit.

解决方案是检出主题分支,从第一次提交运行 rebase --no-ff ,然后将该分支合并回主。

The solution was to checkout the topic branch, run rebase --no-ff from the first commit and then merge that branch back into master.

git checkout topic
git rebase -i --no-ff <C>
git checkout master
git merge topic

这样做的结果是:

fixed–topic   C'–––D'––––––––––––––––––––-
             /                            \
master  A–––B–––E–––F–––G –––> L–––M–––N–––F2
             \     /
topic         C–––D

要深入了解这一点,请阅读该信的最后部分如何使用 - no-ff rebase选项来还原错误的合并重新创建分支。

To really understand this in-depth, read the last portion of the letter How to Revert a Faulty Merge using the --no-ff rebase option to re-create the branch.

这篇关于如何恢复使用战略=我们的合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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