是否可以合并/变基非直接关系分支?

发布于 2024-09-02 09:46:24 字数 132 浏览 2 评论 0原文

作为集成测试,我想先加入几个分支,然后再将它们与我的主分支合并。

他们都背离了师父,自行其道。这是正确的合并没有直接关系的不同分支(例如父/子)?

重新加入分支机构有什么好的做法吗?

提前致谢, 劳尔.

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我是有多爱你 2024-09-09 09:46:24

如果这些分支全部来自 master,它们确实有一个共同的祖先

     y--y--y
    /
x--o--x--x--x--x--x--x
          \
           z--z--z

('o' 是这里的共同祖先)
在这种情况下,在集成分支中合并是一个好方法(重新建立这样的长期分支将涉及重写太多的公共历史)

如果分支确实是独立的,那么git移植点可以在理论允许共同的历史:请参阅如何合并两个分支而不需要共同的祖先?.
但这并不理想,因为嫁接点尚未提交。
过滤器分支可能会使修改永久化,但会重写历史记录。

If those branches come all from master, they do have a common ancestor

     y--y--y
    /
x--o--x--x--x--x--x--x
          \
           z--z--z

('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.

廻憶裏菂餘溫 2024-09-09 09:46:24

如果这些分支都来自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 to git rebase.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文