是否可以合并/变基非直接关系分支?
作为集成测试,我想先加入几个分支,然后再将它们与我的主分支合并。
他们都背离了师父,自行其道。这是正确的合并没有直接关系的不同分支(例如父/子)?
重新加入分支机构有什么好的做法吗?
提前致谢, 劳尔.
As a integration test I would like to join several branches before merging them with my master.
All of them diverged from the master and make it's own way. It is a correct merging different branches with no direct-relationship (e.g. parent/child)??
Is there any good practise for rejoining branches??
Thanks in advance,
Raul.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果这些分支全部来自 master,它们确实有一个共同的祖先
('o' 是这里的共同祖先)
在这种情况下,在集成分支中合并是一个好方法(重新建立这样的长期分支将涉及重写太多的公共历史)
如果分支确实是独立的,那么git移植点可以在理论允许共同的历史:请参阅如何合并两个分支而不需要共同的祖先?.
但这并不理想,因为嫁接点尚未提交。
过滤器分支可能会使修改永久化,但会重写历史记录。
If those branches come all from master, they do have a common ancestor
('o' being the common ancestor here)
In that case, a merge in an integration branch is a good approach (rebasing such long-lived branch would involve rewriting too much public history)
If the branches are truly separate, then a git grafts points could in theory allow for a common history: see How to merge two branches without a common ancestor?.
But that is not ideal, since the graft point is not committed.
A
filter-branch
might make the modification permanent, but that rewrite history.如果这些分支都来自master,那么它们确实有一个共同的祖先。
但是回答你的问题(但不是你的问题),可以合并两个没有共同祖先的历史,例如两个不同的项目,使用 git merge 的“子树”合并策略。
要将一个分支变基到另一个没有共同祖先的分支之上,您需要使用
--root
选项来git rebase
。If those branches come all from master, they do have a common ancestor.
But answering your question (but not your problem), it is possible to merge two histories without common ancestor, for example two different projects, using for example 'subtree' merge strategy of
git merge
.To rebase one branch on top of the other that doesn't have common ancestor, you would need to use
--root
option togit rebase
.