如何将分支合并到GIT中的另一个分支? [英] How to merge a branch to another branch in GIT?

查看:494
本文介绍了如何将分支合并到GIT中的另一个分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个主要的git分支,我在其中创建了一个新的分支bug10101010,现在我不想合并主要bug10101010。到目前为止,一切都很好。
现在我有一个同名产品的不同分支,名为legacy。我不想将bug10101010合并到GIT的遗留分支中。



任何想法?

我可以T只是合并它直接,作为分支bug10101010是从主分支,并在传统的I只需要分支bug10101010与其父分支之间的差异剥离。

解决方案

这很难做到。 Git的节省了合并的历史,如果你在bug10101010提交作为父母cherrypick和点(表示你已经做了合并)Git会假设所有之前的提交(回哪里分割点)作为被合并为好。当你想做一个真正的合并时,给你带来麻烦。另一方面,你可以手动从那个(并且只有那个)特定的提交中生成一个补丁。但是当你稍后进行真正的合并时,这也会给你带来问题,因为它会尝试将你手动处理的提交应用两次。然而,再一次,因为一个分支被命名为遗产我怀疑你不打算无论如何要做到真正的融合,在这种情况下,您选择非常自由地做它无论如何请你。



这里有一个< 关于该主题的有趣的博客帖子


Let me explain the problem in detail.

I have a main git branch on which I created a new side branch bug10101010, now I wan't to merge the bug10101010 to main. So far everything is good. Now I have a different branch of the same product, named legacy. I wan't to merge the bug10101010 to the legacy branch in GIT.

Any ideas?

I can't just merge it directly, as the branch bug10101010 is spin off from the main branch and in the legacy I need only the diff between the branch bug10101010 and its parent branch.

解决方案

This is hard to do. Git saves merge history, and if you "cherrypick" and point at a commit in bug10101010 as a parent (indicating you have done a merge) Git will assume that all commits before that (back to the point where they split) as been merged as well. Giving you problems when you want to do a "real" merge.

On the other hand you can just manually generate a patch from that (and only that) specific commit. But that will also give you problems when you later do the "real" merge, since it tries to apply your manually handled commit twice.

But then again, since one branch is named "Legacy" I suspect that you dont plan to do that real merge anyway, in which case youre pretty much free to do it anyway you please.

Heres an interesting blog post on the topic.

这篇关于如何将分支合并到GIT中的另一个分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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