处理 git 测试和生产分支

Handle git branching for test and production

当使用 git(流程)并拥有 stage/test 环境时,客户正在对开发的事物进行审查,处理未获批准的功能的最佳方式是什么具有哪些特点?

考虑多个开发人员在冲刺或连续工作流程中使用不同功能的场景。这些特性需要由客户审查,并且为了能够在阶段环境中审查这些特性,它们必须合并到开发分支并部署。

比方说,如果已经开发了两个功能,开发团队认为已完成并推送给开发人员。客户审查它们并批准其中一个。但是现在客户想要将批准的功能发布到生产环境中。 dev 分支现在 "polluted" 由无法推送到生产的未批准的功能代码。

处理这种情况的最佳方法是什么?当然实际情况要复杂得多。樱桃采摘是一种解决方案还是应该重新考虑分支机构的整体流程和处理?

那个问题(开发分支被“未批准但已经集成”的功能分支污染)完全描述了Raman Gupta in "How the Creators of Git Do Branching"。
(GitHub 此工作流程的回购:rocketraman/gitworkflow

在您的情况下 (gitflow),您需要在将 dev 合并到 release 之前恢复未批准功能的合并提交。

但是“gitworkflow”使用临时分支,反对 gitflow:

GitFlow advocates having two eternal branches — master and develop

两个工作流(gitflow 或 gitworkflow)都使用“feature”或“topic”分支:

Topic branches are where all the current work is being done — one branch per issue, bug, or feature, and there can be many topic branches undergoing development at once.

主题最终合并到 gitworkflow 中的分支“next”。
然而,一个关键的区别是 next 分支永远不会合并到 master(与永恒分支“develop”相反,后者意味着要合并到 master/release 在 gitflow 中)

Now that the topic has graduated to next, it can be part of a beta, or acceptance release. So every topic on next can now undergo a second round of stabilization, which is exactly the purpose of a beta release / acceptance testing environment.

However, note that with gitworkflow, we still have not committed (no pun intended!) to having this topic as part of our next release to production — it still has not been merged to master.
This is similar in concept to GitFlow’s release branch, but far more flexible and powerful, since master has no dependencies on next whatsoever, nor is next ever merged wholesale into master (unlike the corresponding GitFlow branches develop and release).

如果 next 合并到 master,您如何将功能升级到生产环境?

Once a topic is judged stable enough to release, the topic graduates again and is merged to master (or perhaps maint), again with --no-ff to preserve the complete history of the topic branch.

为什么这样更好:

Note that in gitworkflow, unstable and stable development work is never mixed together on the same branch.

In contrast, with GitFlow I have two choices:

  1. I can test my topic in isolation on its own branch, or
  2. I can merge it to develop for testing.

Neither choice is appealing.

  • The former doesn’t offer a true test of a topic’s stability when deployed together with other ongoing work, and
  • the latter commits the topic to develop perhaps before it is stable.

含义:

In short, in GitFlow there is always an unsolvable tension between the desire to keep development work clean and isolated on a topic branch, and integrating topic branches with other work by merging them to develop to make them visible and testable and to check for conflicts.
Gitworkflow allows both goals to be achieved without sacrificing one for the other.

我认为正确的做法是:

  • 生产 (...)
  • master(开发分支)
  • feature123
  • feature234
  • feature345
  • 特征[数量]

如果可以,请向客户提供一个 feature[number].example.com 域。所以你可以在 master 分支中显示合并之前的所有功能。如果某个功能被拒绝,则绝不能将其合并到 master 中。如果功能被接受,则必须合并。

一个很好的选择也是一个 "staging" 域,在需要时可以在其中部署代码。假设您的客户需要查看 feature42,...只需将 feature42 部署到 customer.example.com 域。

在哪里开发新功能?

feature[number] branch

在哪里显示新功能?

feature[number].example.com

在哪里可以看到下一个 sprint 代码(大师)在工作?

next.example.com

master.example.com

在哪里可以看到生产代码?

www.example.com