将QA分支重新摘要而不是发展
最初,在工作流程中,我有以下分支结构(开发
main
,of
develop
)的功能分支:
main ---\
\-- develop --\
\-- feature --
以后,我们决定添加QA
分支。最初,我制作了QA
开发
的OFF,所以现在的分支结构看起来像这样:
main ---\
\-- develop --\
\-- qa --
\-- feature --
我希望工作流程我们将功能分支合并到开发
,然后将
开发到QA
进行测试,然后QA
in main
以供发布。为此,我需要类似的东西:
main ---\
\-- qa --\
\-- develop --\
\-- feature --
如何从现有的结构(QA
基于开发
)到新的结构(QA 基于
main
和开发
基于QA
)?我认为我需要重新恢复,但不确定如何。
Initially in my workflow, I had the following branch structure (develop
off of main
, feature branches off of develop
):
main ---\
\-- develop --\
\-- feature --
Later on, we decided to add a qa
branch. Initially I made qa
off of develop
, so now the branch structure looks like this:
main ---\
\-- develop --\
\-- qa --
\-- feature --
I want the workflow to be that we merge feature branches into develop
, then develop
into qa
for testing, then qa
into main
for release. For that I would need something like this:
main ---\
\-- qa --\
\-- develop --\
\-- feature --
How can I go from my existing structure (qa
based off of develop
) to the new one (qa
based off of main
and develop
based off of qa
)? I think I need to rebase but not quite sure how.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果其中任何一个有意义,则不发表评论:)并且有一点警告,只有当一个分支可访问而另一个分支无法访问的提交不会引入冲突的更改时,这才有效,以下是 git rebase 的方法用于重塑您的历史记录:
可能需要将最后一个命令替换为 git rebase --onto Development D feature (
D
是原始的提示/头部)代码>开发分支,之前rebase)
你可能会欣赏一些 ASCII 艺术的优点:
初始状态
rebase --onto maindevelop qa
这一个很简单,它只是在 master/B 之上重新创建两个提交。
rebase qadevelop
这将在 qa/H' 之上重新创建开发的提交。请注意,原始的 C 和 D 提交仍然可以通过 ref
feature
访问,因此是功能分支历史的一部分。rebase 开发功能
这应该自动检测到 C 和 D 已经作为 C' 和 D' 包含在新上游中,并跳过应用它们。如果自动检测不起作用,请参阅上面的替代命令。
一旦
feature
引用被移动,原始的 C 和 D 提交就变得无法访问。当然,所有提交都将被分配新的提交 ID(原始提交已消失,但新的提交将在其位置创建)。
Not commenting if any of that makes sense :) and with a bit of warning that this will only work if the commits reachable by one branch but not the other do not introduce conflicting changes, here's how
git rebase
can be used to reshape your history:It could be required to replace that last command with
git rebase --onto develop D feature
(D
being the tip/head of the originaldevelop
branch, before rebasing)You might appreciate some ASCII art goodness:
Initial state
rebase --onto main develop qa
This one is trivial, it simply recreates both commits on top of master/B.
rebase qa develop
This will recreate develop's commit on top of qa/H'. Note that the original C and D commits are still reachable through ref
feature
, thus part of the history of the feature branch.rebase develop feature
This should automatically detect that C and D are already contained in the new upstream as C' and D' and skip applying them. If the automatic detection does not work, see above for an alternative command.
Once the
feature
ref has been moved, the original C and D commits become unreachable.Of course all commits will be assigned new commit ids (the original commits are gone, but new commits are created in their place).