"Once upon a time I was reading a Popular Mechanics article, the title of which eludes me. Something about playing different music for different parts of a dance floor. They were describing a way to focus sound towards different people."
Trunk-based development is a version control management practice where developers merge small, frequent updates to a core “trunk” or main branch.
Gitflow and trunk-based development.
Gitflow, which was popularized first, is a stricter development model where only certain individuals can approve changes to the main code. This maintains code quality and minimizes the number of bugs.
Trunk-based development is a more open model since all developers have access to the main code. This enables teams to iterate quickly and implement CI/CD.
Developers can create short-lived branches with a few small commits compared to other long-lived feature branching strategies.
Gitflow is an alternative Git branching model that uses long-lived feature branches and multiple primary branches.
Gitflow also has separate primary branch lines for development, hotfixes, features, and releases.
Trunk-based development is far more simplified since it focuses on the main branch as the source of fixes and releases.
Trunk-based development eases the friction of code integration.
trunk-based development model reduces these conflicts.
Adding an automated test suite and code coverage monitoring for this stream of commits enables continuous integration.
When new code is merged into the trunk, automated integration and code coverage tests run to validate the code quality.
Trunk-based development strives to keep the trunk branch “green”, meaning it's ready to deploy at any commit.
With continuous integration, developers perform trunk-based development in conjunction with automated tests that run after each committee to a trunk.
If trunk-based development was like music it would be a rapid staccato -- short, succinct notes in rapid succession, with the repository commits being the notes.
Instead of creating a feature branch and waiting to build out the complete specification, developers can instead create a trunk commit that introduces the feature flag and pushes new trunk commits that build out the feature specification within the flag.
Automated testing is necessary for any modern software project intending to achieve CI/CD.
Short running unit and integration tests are executed during development and upon code merge.
Automated tests provide a layer of preemptive code review.
Once a branch merges, it is best practice to delete it.
A repository with a large amount of active branches has some unfortunate side effects
Merge branches to the trunk at least once a day
The “continuous” in CI/CD implies that updates are constantly flowing.