简体   繁体   English

Git 流程和功能分支的同步

[英]Git flow and syncing of feature branches

I am coming from Perforce, so please excuse my beginner question.我来自 Perforce,所以请原谅我的初学者问题。 I am evaluating git and its integration model.我正在评估 git 及其集成模型。 In Perforce I have a master and a develop branch.在 Perforce 中,我有一个master和一个develop分支。 feature1 and feature2 are branched of develop - so similar to git flow, except that changes in master go back into the feature branches, so a circular integration model. feature1feature2是支链的develop -如此的相似git的流量,但在改变master返回到feature分支,所以圆形的整合模式。

   master-------+-----+
   ⬆           |     |
   +-develop    |     |
     ⬆         ⬇     | 
     +-----feature1-+ |
     ⬆               ⬇
     +------------feature2

That solves one big problem in our C++ pipeline.这解决了我们 C++ 管道中的一个大问题。 Someone merges his features into develop and let's assume there is a compiler error due to an incorrectly resolved conflict, etc. (developers simply can't resolve all issues locally because of 8 different targets).有人将他的功能合并到develop ,让我们假设由于错误解决的冲突等导致编译器错误(由于 8 个不同的目标,开发人员根本无法在本地解决所有问题)。 So they submit it, compile it on the build server and fix any issues that are left.所以他们提交它,在构建服务器上编译它并修复遗留的任何问题。 Only if develop compiles on all platforms, the changes will be merged into master .只有在所有平台上都编译了develop ,更改才会合并到master So it's like a safety branch so nothing broken ends up in master .所以它就像一个安全分支,所以在master没有任何破坏。 With this solution every developer can be assured that any integrate from master into his feature branch is clean and works.有了这个解决方案,每个开发人员都可以确保从master到他的feature分支的任何集成都是干净的并且有效。

Now my question, how is this achieved with git flow?现在我的问题是,这是如何通过 git flow 实现的? How are features coming from one feature branch into another without any problems?功能如何从一个功能分支到另一个功能分支而没有任何问题?

Branch policies分行政策

How to only get running builds on your master branch如何只在主分支上运行构建

For my understanding, pure git does not offer such a feature.据我了解,纯 git 不提供这样的功能。 Basically you can merge each commit together with each other without limitations.基本上,您可以无限制地将每个提交合并在一起。

Nevertheless what you need are so called branch policies.然而,您需要的是所谓的分支策略。 These are not part of pure git but some vendors offer them.这些不是纯 git 的一部分,但一些供应商提供它们。 So it is all about where to host your repo.所以这完全是关于在哪里托管你的回购。 I do not want advertise Microsoft but in my opinion Azure DevOps is exactly what you need.我不想为 Microsoft 做广告,但在我看来 Azure DevOps 正是您所需要的。

Here is a link about branch policies in git for Azure DevOps. 是有关 Azure DevOps git 中分支策略的链接。 I recommend the part about build validation which only allows a merge on the master branch if the build was successful.我推荐关于构建验证的部分,如果构建成功,它只允许在 master 分支上进行合并。

Other vendors may offer this stuff aswell but I do not know exactly since I am mainly working with Azure DevOps.其他供应商也可能提供这些东西,但我不确切知道,因为我主要使用 Azure DevOps。

Git branching model Git 分支模型

How to work with your branches如何与您的分支机构合作

When it comes to git workflows and and branching models there are various approaches, each with advantages and disadvantages.当谈到 git 工作流和分支模型时,有多种方法,每种方法都有优点和缺点。 If you want to keep working with the basic idea of your branches from Perforce, I'd recommend this branching model.如果您想继续使用 Perforce 的分支的基本思想,我会推荐这个分支模型。

Regarding your question关于你的问题

if "ring/cycle merges/integrations" are even possible, common or recommended如果“环/循环合并/集成”甚至可能,常见或推荐

I think I can answer this question with „Yes, it is possible and common sense but I would not call them rings or circles“.我想我可以用“是的,这是可能的和常识,但我不会称它们为环或圆”来回答这个问题。 The branching model presented on the website is a good example for how to use merges to exchange information between your branches.网站上提供的分支模型是如何使用合并在分支之间交换信息的一个很好的例子。

Conclusion结论

  • Use the branch policies to protect your master branch.使用分支策略来保护您的主分支。 Only working code will be committed.只会提交工作代码。
  • Use the branching model for merging changes between branches使用分支模型合并分支之间的更改

Cheers and good luck!干杯,祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM