git:将功能分支合并到主线的较早部分 [英] git: merging feature branches into earlier part of master line

查看:184
本文介绍了git:将功能分支合并到主线的较早部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我敢肯定这已经被问过了,但是我什至不确定我要寻找的术语是什么.

I'm sure this has been asked before but I'm not even really sure what the terms I am looking for are.

我有一个看起来像这样的分支结构:

I have a branch structure that looks like this:

startoftime -> A -> B -> C -> D (master head)
                    |
                    -> X -> Y (feature1 head)(tag T)
                    |
                    -> Q -> R (feature2 head)

基本上,我从提交B创建了两个功能分支,并在其中进行了开发.其中一个的标头上有一个标签,该标签从原始根目录反映了它的整体历史.现在,我想将它们折回母版,但理想情况下,我希望它们出现在母版上新内容的出现之前,而不是之后,因此将当前的母版位置保留在原位置.理想情况下,我想要这样:

Essentially I created two feature branches from commit B and did development in them. The head of one of them has a tag on it that reflects its overall history from the original root. Now I want to fold them back into master, but ideally I'd like them to appear in the history before the new stuff on master, not after, so leaving the current master head where it is. Ideally I'd like this:

startoftime -> A -> B -> X -> Y -> Q -> R -> C -> D (master head)
                              |
                            (tag T)

我应该在这里查看哪些概念或命令?

What are the concepts or commands I should be looking at here?

有人建议rebase可能是我在这里追求的.尽管我可以保证除我之外没有人退出/签出过这三个分支,但所有这三个分支都已被推送到我的遥控器中.我仍然可以使用rebase吗?

There is a suggestion that rebase might be what I'm after here. All three of these branches have been pushed to my remote already, although I can guarantee that no one but me has pulled from it/checked it out. Can I still use rebase?

谢谢.

推荐答案

只要没有其他人使用过您的分支机构,那么重新建立基准就不是问题.不管是否远程"都没有关系.下次进行推送时,只需使用--force.

Rebases aren't an issue as long as no one else has used your branches. Doesn't matter if it's "remote" or not. You'll just have to use --force the next time you do a push.

话虽这么说,我想鼓励您重新考虑只使用合并.您的历史记录仍将显示功能开发时间的时间表,但也将更准确地反映您并行工作以及将其集成到主分支中的历史.如果您进行了变基,则当前的Q与您最初使用它时的Q会有所不同,可能会达到无法正常工作的地步,就像您必须重新使用它一样.此外,如果出于某些原因需要,可以更轻松地删除feature1或feature2.

That being said, I'd like to encourage you to reconsider just using a merge. Your history will still show the timeline of when the features were developed, but it will also more accurately reflect the history of you working in parallel, as well as when you integrated it into your master branch. If you do a rebase, your current Q will be different than Q was when you were originally working on it, possibly to the point where it doesn't work like you expect if you ever have to go back to it. Also, it makes it easier to remove feature1 or feature2, should it be required for some reason.

这篇关于git:将功能分支合并到主线的较早部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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