将QA分支重新摘要而不是发展

发布于 2025-01-19 23:58:02 字数 870 浏览 2 评论 0原文

最初,在工作流程中,我有以下分支结构(开发 mainof 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 技术交流群。

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

发布评论

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

评论(1

寄离 2025-01-26 23:58:02

如果其中任何一个有意义,则不发表评论:)并且有一点警告,只有当一个分支可访问而另一个分支无法访问的提交不会引入冲突的更改时,这才有效,以下是 git rebase 的方法用于重塑您的历史记录:

git rebase --onto main develop qa
git rebase qa develop
git rebase develop feature

可能需要将最后一个命令替换为 git rebase --onto Development D feature (D 是原始 的提示/头部)代码>开发分支,之前rebase)

你可能会欣赏一些 ASCII 艺术的优点:

初始状态
A-B               -- master
   \     ,-G-H    -- qa
    `-C-D         -- develop
         `-E-F    -- feature
rebase --onto maindevelop qa

这一个很简单,它只是在 master/B 之上重新创建两个提交。

   ,-G'-H'        -- qa
A-B               -- master
   \
    `-C-D         -- develop
         `-E-F    -- feature
rebase qadevelop

这将在 qa/H' 之上重新创建开发的提交。请注意,原始的 C 和 D 提交仍然可以通过 ref feature 访问,因此是功能分支历史的一部分。

   ,-G'-H'        -- qa
A-B      \        -- master
   \      `-C'-D' -- develop
    `-C-D
         `-E-F    -- feature
rebase 开发功能

这应该自动检测到 C 和 D 已经作为 C' 和 D' 包含在新上游中,并跳过应用它们。如果自动检测不起作用,请参阅上面的替代命令。

一旦 feature 引用被移动,原始的 C 和 D 提交就变得无法访问。

   ,-G'-H'               -- qa
A-B      \               -- master
          `-C'-D'        -- develop
                `-E'-F'  -- feature

当然,所有提交都将被分配新的提交 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:

git rebase --onto main develop qa
git rebase qa develop
git rebase develop feature

It could be required to replace that last command with git rebase --onto develop D feature (D being the tip/head of the original develop branch, before rebasing)

You might appreciate some ASCII art goodness:

Initial state
A-B               -- master
   \     ,-G-H    -- qa
    `-C-D         -- develop
         `-E-F    -- feature
rebase --onto main develop qa

This one is trivial, it simply recreates both commits on top of master/B.

   ,-G'-H'        -- qa
A-B               -- master
   \
    `-C-D         -- develop
         `-E-F    -- feature
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.

   ,-G'-H'        -- qa
A-B      \        -- master
   \      `-C'-D' -- develop
    `-C-D
         `-E-F    -- feature
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.

   ,-G'-H'               -- qa
A-B      \               -- master
          `-C'-D'        -- develop
                `-E'-F'  -- feature

Of course all commits will be assigned new commit ids (the original commits are gone, but new commits are created in their place).

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