What is the best branching strategy?

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

Mateusz K?osiński

Lead Software Engineer (.NET/Angular) w gravity9

1 个月

Nice article!

Marcin Lach

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?

Thomas Stidsborg Sylvest

Software Developer & cleipnir.net author ??

1 个月
Tarik Minogue

Scrum Master | Agile Delivery Management

1 个月

Really good read!

Bart?omiej Dylik

?? Azure Cloud Architect | CCoE | Husqvarna Group

1 个月

Seems you've had a productive weekend! ??

要查看或添加评论,请登录

Grzegorz Jońca的更多文章

  • Building Simple Agent in M365 Copilot

    Building Simple Agent in M365 Copilot

    Introduction Some time ago, I received a license for M365 Copilot and began exploring its core functionalities, such as…

    2 条评论

社区洞察

其他会员也浏览了