在Git中重新进行合并 [英] Re-doing a reverted merge in Git

查看:103
本文介绍了在Git中重新进行合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一些问题:我在Git中有一个特定于问题的分支 28s ,我将它合并到了一般的开发分支。原来我做得太快了,所以我用git-revert来取消合并。然而,现在是把 28s 合并到 develop 的时候了,但是git-merge命令会看到原来的合并,并高兴地宣布一切正常,分支机构已经合并。现在我该怎么做?创建一个还原还原28s - >开发'提交?似乎并不是一个好的方法,但我现在无法想象任何其他的东西。



树结构看起来像:

>

解决方案

你必须恢复恢复。取决于你是如何回复的,可能并不像听起来那么容易。查看关于此的官方文档主题

  --- o --- o --- o --- M --- x --- x --- W --- x --- Y 
/
--- A --- B ----------------- --C --- D

允许:

  --- o --- o --- o --- M --- x --- x ------- x ----- -  * 
/ /
--- A --- B ------------------- C --- D




但是这一切工作吗?当然可以。你可以恢复合并,从纯粹的技术角度
开始,git非常自然地做到了这一点,并且没有真正的
麻烦。

它只是认为它是从merge before merge 到
合并后的状态,就是这样。

没有什么复杂的,没有什么奇怪的,
没有什么真正危险的。 Git会在不考虑它的情况下做到这一点。

因此,从技术角度来看,从工作流中恢复合并
没有任何问题角度这是你通常应该尝试
避免



如果可能,例如,如果您发现合并的问题
添加到主树中,而不是恢复合并,确实很难


  • 将问题分解为您合并的分支,然后修复它,或者尝试恢复导致它的单个提交。



  • 是的,它更复杂,不,它并不总是有效(有时候
    的答案是:哎呀,我真的不应该有合并它,因为它不是
    准备好了,我真的需要撤销合并的所有)。因此,您的
    真的应该恢复合并,但是当您想重新合并时,您现在需要通过恢复回复来完成合并。



I have run into a bit of a problem here: I had a problem-specific branch 28s in Git, that I merged in the general develop branch. Turns out I had done it too fast, so I used git-revert to undo the merge. Now, however, the time has come to merge 28s into develop, but git-merge command sees the original merge, and happily announces that all is well and branches have been already merged. What do I do now? Create a 'Revert "Revert "28s -> develop"" ' commit? Doesn't seem to be a good way to do it, but I can't imagine any other at the moment.

What the tree structure looks like:

解决方案

You have to "revert the revert". Depends on how did you revert that, it may not be as easy as it sounds. Look at the official document on this topic.

---o---o---o---M---x---x---W---x---Y
              /
      ---A---B-------------------C---D

to allow:

---o---o---o---M---x---x-------x-------*
              /                       /
      ---A---B-------------------C---D

But does it all work? Sure it does. You can revert a merge, and from a purely technical angle, git did it very naturally and had no real troubles.
It just considered it a change from "state before merge" to "state after merge", and that was it.
Nothing complicated, nothing odd, nothing really dangerous. Git will do it without even thinking about it.

So from a technical angle, there's nothing wrong with reverting a merge, but from a workflow angle it's something that you generally should try to avoid.

If at all possible, for example, if you find a problem that got merged into the main tree, rather than revert the merge, try really hard to:

  • bisect the problem down into the branch you merged, and just fix it,
  • or try to revert the individual commit that caused it.

Yes, it's more complex, and no, it's not always going to work (sometimes the answer is: "oops, I really shouldn't have merged it, because it wasn't ready yet, and I really need to undo all of the merge"). So then you really should revert the merge, but when you want to re-do the merge, you now need to do it by reverting the revert.

这篇关于在Git中重新进行合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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