简体   繁体   中英

Git flow and syncing of feature branches

I am coming from Perforce, so please excuse my beginner question. I am evaluating git and its integration model. In Perforce I have a master and a develop branch. 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.

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

That solves one big problem in our C++ pipeline. 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). 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 . So it's like a safety branch so nothing broken ends up in master . With this solution every developer can be assured that any integrate from master into his feature branch is clean and works.

Now my question, how is this achieved with 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. 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. 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.

Here is a link about branch policies in git for Azure DevOps. I recommend the part about build validation which only allows a merge on the master branch if the build was successful.

Other vendors may offer this stuff aswell but I do not know exactly since I am mainly working with Azure DevOps.

Git branching model

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. If you want to keep working with the basic idea of your branches from Perforce, I'd recommend this branching model.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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