What is the best branching strategy?
Our Branching Strategy Journey
Recently, we had a discussion within our platform team about establishing recommendations and then creating documentation for other teams on branching strategies for storing Infrastructure as Code (IaC) files as well as application code. After some interesting and intensive discussions, we agreed on the Trunk-Based branching strategy, following the "Keep It Simple, Stupid" (KISS) approach. I explored this topic extensively and decided to create this note for future reference, which might also be helpful for others. In such decisions, the answer often lies in the specific context and requirements of the project. It depends on factors like team size, project complexity, and the desired pace of delivery. While there is no silver bullet, making a thoughtful decision based on informed discussions is crucial.
Branching Strategies Compared
There are several branching strategies, ranging from the quite complex (like Git Flow) to the simplest (like Trunk-Based). Other notable strategies include GitHub Flow, GitLab Flow, Environment Branching, and more. In our case, we focused primarily on storing Infrastructure as Code (IaC) files and, as a result, narrowed our discussion to two strategies: Environment Branching and Trunk-Based. The idea behind Environment Branching was to adopt a secure approach where each environment has its own branch. This allows better control over the source code and releases while reducing the chance of potential bugs. On the other hand, Trunk-Based branching is very simple and, therefore, easy to use. It involves a single main branch where developers integrate their changes continuously, enabling faster delivery and streamlined workflows.
Below is a table comparing the two:
Why We Chose Trunk-Based?
To keep it simple, stupid! (KISS) As mentioned at the beginning, there is no silver bullet. Therefore, starting with a simple strategy and adding complexity over time makes sense. Simple solutions are easier to understand and implement, which is especially important when creating recommendations. Although the first option (Environment Branching) was more robust, it was also more complex. This complexity could lead to misunderstandings among teams using it, causing issues with merge conflicts and different code versions across branches.
Want to Learn More?
For those interested in diving deeper into Git branching strategies, here are some helpful resources I found during my research. Git branching strategy - MS Learn
Lead Software Engineer (.NET/Angular) w gravity9
1 个月Nice article!
Senior Backend Developer | C#, .Net, Azure | Achieving Business Goals with (and without) Code
1 个月And how did you map multiple envs into single trunk? I missed that in your article. Did you add separate folder for each env?
Software Developer & cleipnir.net author ??
1 个月Martin Mortensen
Scrum Master | Agile Delivery Management
1 个月Really good read!
?? Azure Cloud Architect | CCoE | Husqvarna Group
1 个月Seems you've had a productive weekend! ??