修改已合并的 git 主题分支的最佳实践

发布于 2024-09-18 02:07:54 字数 826 浏览 2 评论 0原文

在我的公司编写新故事时,我们使用以下 git 工作流程:

  1. 从 master(生产/稳定)创建一个主题分支
  2. 根据需要创建任意数量的提交来实现功能。
  3. 将该主题分支的 git merge --squash 到 qa 分支上。
  4. QA 人员进行审查。
  5. 如果好的话,代码会被合并到ua分支中。如果用户验收团队认可,它就会被合并到 master 并最终部署。
  6. 如果审核不通过,开发商需要修复。本质上是在步骤 2 中重新启动该过程。

注意:从点代码合并到 qa 分支到 qa 拒绝/接受它的时间可能长达两周。

如果没有问题,那么代码最终将成为主控。但是,我正在寻找 QA 发现问题并且您必须修复它时的最佳实践。我想要的是最终让一个 qa 分支看起来尽可能“原始”。

在我看来,以下是选项:

  1. 在 qa 分支中恢复原始压缩的提交,从 qa 重新调整主题分支,修复主题分支中的代码,再次将其合并到 qa 中。问题:留下令人讨厌的恢复提交。
  2. 删除现有的主题分支,从 qa 分支重新创建它,创建一个简单的提交来修复问题,合并回 qa。问题:将功能的代码更改分散到时间和地点不同的提交中。
  3. 取消对 qa 的压缩合并,将单个提交从 qa 重新调整到现有主题分支,用另一个提交修复,合并到 qa 中。问题:多次提交使得在移动到 ua 分支然后再到 master 时跟踪更改变得困难。

问题:当合并的代码可能需要修复时,是否有通过多个长期分支(master -> topic -> qa -> ua -> master)移动单个功能的多个提交的最佳实践?

We use the following git workflow at my company when coding up a new story:

  1. Create a topic branch off of master (production/stable)
  2. Create as many commits as desired to implement feature.
  3. do a git merge --squash of that topic branch onto the qa branch.
  4. QA people review.
  5. If good, the code is merged into the ua branch. If the User Acceptance team blesses it, it gets merged to master and ultimately deployed.
  6. If it fails review, the developer needs to fix. Essentially restarting the process at step 2.

Note: It can be up to two weeks from the point code is merged to qa branch and the time qa rejects/accepts it.

If there are no issues, then the code eventually makes it into master. However, I'm seeking best practices for when QA finds an issue and you have to fix it. What I'd like is to end up with a qa branch looking as "pristine" as possible.

As I see it, here are the options:

  1. Revert the original squashed commit in qa branch, rebase topic branch off of qa, fix your code in the topic branch, merge it into qa again. Problem: leaves icky revert commit around.
  2. Delete existing topic branch, recreate it from qa branch, create a simple commit to fix problem, merge back into qa. Problem: spreads code changes for feature across commits distinct in time and place.
  3. Do away with squashed merges to qa, rebase individual commits from qa to existing topic branch, fix with another commit, merge into qa. Problem: multiple commits make it difficult to track changes as they move to ua branch and then to master.

Question: Is there a best practice for moving multiple commits for a single feature through multiple long-lived branches (master -> topic -> qa -> ua -> master) when merged code may need to be fixed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

世界如花海般美丽 2024-09-25 02:07:55

根据经验,保留一个分支来修复 qa 或 ua 或 master 中发现的内容的想法不太好,因为它人为地链接在一起(在同一分支内),最终导致完全不同的开发工作。
您在“qa”之后修复的错误通常比“ua”或“<代码>主控'。

所以我会选择 2.,但没有“删除主题分支”部分,只使用“创建新主题分支”来进行开发周期中需要执行的特定修复/演变。

From experience, the idea to keep one branch to fix what is found in qa or ua or master doesn't go very well, as it artificially links together (within a same branch) what ends up being different development efforts altogether.
The bug you are fixing after 'qa' are generally more straightforward (because found sooner in the development life-cycle) than the ones found in 'ua' or in 'master'.

So I would go with 2., but without the 'delete topic branch' part, only with 'create new topic branches' for the specific fixes/evolutions you need to do along the development cycle.

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