Optimization Glossary

Trunk-Based Development

What Is Trunk-Based Development?

Trunk-based development is software development strategy where engineers merge smaller changes more frequently into the main codebase and work off the trunk copy rather than work on long-lived feature branches.

Why Trunk Based Development

With many engineers working in the same code-base, it's important to have a strategy for how individuals work together. To avoid overriding each other's changes, engineers create their own copy of the codebase, called branches. Following an analogy of a tree, the master copy is sometimes called the mainline or the trunk. The process of incorporating the changes of an individual's copy into the main master trunk is called merging.

To understand how trunk-based development, it's useful to first look at the alternative strategy, feature branch development.

In feature branch development, individual software developers or teams of engineers do not merge their new branch until a feature is complete, sometimes working for weeks or months at a time on a separate copy.

feature branch development This long stretch of time can make the process of merging difficult because the trunk or master has likely changed due to other engineers merging their code changes. This can result in a lengthy code review process where the changes in different pull requests are analyzed to resolved merge conflicts.

Benefits of Trunk Based Development

Trunk-based development takes a more continuous delivery approach to software development, and branches are short-lived and merged as frequently as possible. The branches are smaller because they often contain only a part of a feature. These short-lived branches make the process of merging easier because there is less time for divergence between the main trunk and the branch copies.

trunk-based-development Thus, trunk-based development is a methodology for releasing new features and small changes quickly while helping to avoid length bug fixes and "merge hell". It is a growing popular devops practice among agile development teams, and is often paired with feature flags to ensure that any new features can be rolled back quickly and easily if any bugs are discovered.