Git合并与Cherry-Pick的两个不同分支 [英] Git merge vs cherry-pick for two differing branches
问题描述
我有两个没有共同祖先的分支,我们称它们为 master
和 other
.它们的内容差异很大,必须保留.新更改几乎总是在 master
上完成,并且通过一些手动合并精心挑选给 other
,这是无法消除的.这也不会改变.
I'm having two branches without a common ancestor, let's call them master
and other
. Their content differs a lot and this has to stay. New changes are nearly always done on master
and cherry-picked to other
with some manual merging, which can't be eliminated. This won't change either.
我想知道将 master
伪装成这样的 other
的后果是什么
I wonder what are the consequences of fake-merging master
into other
like this
git checkout other
git merge -s ours master
,然后总是合并而不是挑剔.优点很明显:
and then always merging instead of cherry-picking. The advantages are clear:
- 它消除了记住要摘东西的需要
- 它允许一次合并多个更改(有时可能更容易)
- 它在分支之间建立了清晰的关系
我可以想象,在极少数情况下,不需要将某些东西带入另一个分支,这会使我的生活变得更加艰难,但这并不是真正的问题.在开始之前,我想知道我是否没有任何不利之处?
I can imagine that it makes my life a bit harder in the rare cases when something doesn't need to be picked into the other branch, but this is no real problem. Before I do it, I'd like to know if there are any disadvantages I'm unaware of?
推荐答案
没有明显的劣势,尤其是与采摘樱桃相比.
No obvious disadvantages, especially when compared to the ones of cherry-picking, namely;
因此,伪造合并使您可以将合并的共同祖先重置为最近的提交,然后从那里仅合并您需要的内容.
So fake merging allows you to reset the merge common ancestor to a more recent commit, and from there merge only what you needs.
请注意,有一种解决方案用于合并除一个或两个以外的所有文件:
Note there are solution for merging all files except one or two:
git reset <paths>...
git add -p <paths>...
这篇关于Git合并与Cherry-Pick的两个不同分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!