[英]Git workflow for a new dev project
I am starting a new Project and it has been decided that we shall use git for our version control. 我正在启动一个新项目,并且决定将git用于我们的版本控制。
It is a project which involves development of multiple components / Microservices from scratch. 这是一个涉及从头开始开发多个组件/微服务的项目。
To address the complexities in our organisation where we have junior developers, senior developers, dev leads, architects etc., I was looking to use a git workflow based more or less on gitflow, so that we can ensure that developers can work on feature branches and before moving on to the develop branch, we have some code review process in place. 为了解决我们拥有初级开发人员,高级开发人员,开发主管,架构师等的组织中的复杂性,我一直在寻找使用或多或少基于gitflow的git工作流,以便确保开发人员可以在功能分支上工作在进入开发分支之前,我们已经进行了一些代码审查过程。 I want to have master branch which corresponds to the production / production ready code and release branches to signify the current release in progress.
我想拥有与生产/生产就绪代码相对应的master分支和release分支,以表示当前正在进行的发行。
It is an agile project so my idea is to have develop branch corresponding to the sprint code (unit tested and reviewed) and the release branch corresponding to the release (=3 sprints). 这是一个敏捷项目,所以我的想法是拥有一个与sprint代码相对应的development分支(已测试和审查的单元)和一个与发行版相对应的release分支(= 3个sprint)。
The only issue I am facing is how to define the master branch and the relationship between master and develop at the beginning. 我面临的唯一问题是如何在开始时定义master分支以及master与development之间的关系。
Since it is a new dev project, we begin with no production code and everything would basically start from feature branches, move to develop, release and then the master when we have the production ready code. 由于这是一个新的dev项目,因此我们从没有生产代码开始,并且基本上所有东西都将从功能分支开始,然后转移到开发,发布,再到拥有生产就绪代码的母版。
Any suggestions on how to handle this in a good way and also, is this a good idea 关于如何以良好方式处理此问题的任何建议,也是一个好主意
Thanks in advance 提前致谢
First create a master branch and then from the master branch create other branches. 首先创建一个master分支,然后从master分支创建其他分支。 For your reference, I find this gitflow branching model diagram helpful and have successfully in multiple projects.
供您参考,我发现此 gitflow分支模型图很有用,并且在多个项目中均成功。
Don't over do it. 不要结束。 First start off with the simplest branching strategy and then depending upon the complexity and need you may create or adapt to more complex branching strategy.
首先从最简单的分支策略开始,然后根据复杂性和需要,您可以创建或适应更复杂的分支策略。
I think gitflow
is just fine for a project as you describe it. 我认为
gitflow
对于您所描述的项目来说就很好。
If you just start, I would create the master
but leave it empty. 如果您只是开始,我将创建
master
但将其保留为空。 The develop
can be filled with static files (.gitgnore or something like that). 可以用静态文件(.gitgnore或类似的文件)填充
develop
。 Then you start developing in feature
branches and merge to develop
. 然后,您开始在
feature
分支中进行develop
并合并以进行develop
。 After three sprints you create a release
branch and do your extended tests. 经过三个冲刺后,您将创建
release
分支并进行扩展测试。
After all tests pass and you are willing to release your code, you merge into master
. 在所有测试通过并愿意发布代码之后,您将合并为
master
。 So you first merge to master after three months from now. 因此,从现在开始三个月后,您将首先合并为母版。
First, if you're asking this question, you're going to want to start off with a clean, simple flow, then once everyone on the team is rowing ahead well, you can consider incorporating additional branches or level. 首先,如果您要问这个问题,那么您将要以干净,简单的流程开始,然后,一旦团队中的每个人都顺利前进,您可以考虑合并其他分支或级别。 Don't be surprise if you find you don't need any!
如果您发现不需要任何东西,请不要感到惊讶! It can be a non-trivial task trying to keep separate parallel branches all in sync, with an understandable commit log when you're cherry picking features between them.
尝试使单独的并行分支保持全部同步,并且当您在它们之间挑选功能时,具有易于理解的提交日志,这可能是一项艰巨的任务。
NOTE: the squash merges below are for only finished features being merged into master .
注意:以下壁球合并仅适用于将完成的特征合并到master中 。 As you develop a feature, if you periodically need to update your feature branch from master, don't squash your update merges from master.
开发功能时,如果您定期需要从master更新功能分支, 请不要从master 压榨更新合并 。
Some folks prefer keeping individuals sub-commits of each feature branch when merging back into master.
一些人更喜欢在合并回母版时让每个子分支的个人子提交。 I don't, but feel to exclude the squashing, it does't chage the workflow.
我没有,但是要排除挤压,它不会浪费工作流程。
I suggest you use this simple flow: 我建议您使用以下简单流程:
HEAD
of master is for all intents develop
HEAD
主是所有意图develop
release-2.4
)--this never merges back to master. release-2.4
),该分支永远不会合并回master。 2.4.0
2.4.0
2.4.1
2.4.1
Release don't have to be at HEAD
you can use any commit after the last release branch for that. 发布不必位于
HEAD
您可以在最后一个发布分支之后使用任何提交。
Once you've got this running smoothly, you can try to incorporating additional 'staging/develop' branches, I think you'll find limited value and much headache keeping them clean and in sync. 一旦运行顺利,就可以尝试合并其他“ staging / develop”分支,我认为您会发现价值有限,并且很难保持其清洁和同步。 I've consistently found trying to keep separate develop and master branches to be more work than value.
我一直发现尝试保持独立的开发分支和主分支是更多的工作,而不是价值。
One of the greatest benifits of this flow is how clean your history is. 此流程的最大好处之一就是您的历史记录很干净。 If you look at the network graph of it it github it's one continual chain, with only feature branches being worked on, (squashed) feature commits to master), and release branches that never merge back in. Anybody can understand clearly everything without a local git guru to interpret and without deep understanding of any idiosyncratic dev process your company may have.
如果您查看它的网络图github,它是一个连续的链,仅处理功能分支,将(压缩的)功能提交给master),然后释放从未合并的分支。任何人都可以清楚地理解所有内容,而无需本地git guru来解释您的公司,并且可能没有深入了解您的公司的任何特有开发过程。
Here are a few options: 以下是一些选择:
The idea behind git flow is that developers build and contribute to a "develop" branch and once the powers-that-be decide it's about time to do a release, you "cut" off of that branch and create a release branch to refine until it's good enough to actually be released. git flow背后的想法是,开发人员构建并为“ develop”分支做出贡献,一旦有权力决定是时候发布了版本,您就可以“切断”该分支并创建一个release分支进行优化,直到足以被实际释放。
Pros: 优点:
Cons: 缺点:
This is one that I think is the most straight forward but definitely has drawbacks. 我认为这是最直接的方法,但肯定有缺点。 The idea is that all features are branched off of master (which matches production at all times) with the assumption that these branches can be merged into ANY branch at ANY time.
这个想法是所有功能都从master分支(始终与生产匹配),并假设这些分支可以随时合并到ANY分支中。 When you are ready to start testing a release, you simply make a new Release_v99 branch (with an appropriate name) off of the master branch.
准备开始测试发行版时,您只需在master分支上创建一个新的Release_v99分支(具有适当的名称)即可。 You merge in the feature branches you want to be released, then test against the Release_v99 branch.
您将合并到要发布的功能分支中,然后针对Release_v99分支进行测试。
Pros: 优点:
Cons: 缺点:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.