Trunk-based development is a branching strategy where everyone merges small changes into one shared branch (the trunk, usually main) at least once a day, instead of working for weeks on long-lived feature branches. If your merges are painful, your releases are late or your branches drift away from main, this is the model most CI/CD guidance points to. This guide covers what it is, when it fits, ten practices, and Git commands and a feature flag example that were run for this post.
The definitions come from DORA (Google Cloud) and trunkbaseddevelopment.com, linked where used. The Git and C# examples were run on Git 2.50.1 and .NET SDK 10.0.401. Team-process advice reflects those sources and general practice, not a measurement of your team.

Schematic drawing of the idea, not real repository data.
- What is trunk-based development?
- Origin and merge hell: why trunk-based development exists
- Is trunk-based development feasible for your team?
- Feature toggles (flags) keep unfinished work off
- Benefits of trunk-based development
- Best practices of trunk-based development
- Common problems and what was tested
- Summary
- FAQ
What is trunk-based development?
DORA describes two patterns. With feature branches, a developer or a group works in isolation until the feature is done, then merges it. With trunk-based development, each developer divides the work into small batches and merges into the trunk at least once, potentially several times, a day. DORA says branches in this model typically last no more than a few hours. The trunkbaseddevelopment.com site defines it as collaborating on code in a single branch called the trunk and resisting pressure to create other long-lived development branches. The trunk is called main in modern Git (older repositories use master).
Origin and merge hell: why trunk-based development exists
Long-lived branches collect changes that nobody else has seen. When they finally merge, the merge is large, conflicts are numerous, and the combined code has never been built or tested together. DORA notes that this style often needs extra stabilizing work and code freeze periods, because large merges frequently introduce bugs. Trunk-based development attacks the cause: keep each integration small, and do it often, so conflicts stay small and are found while the change is still fresh.
Is trunk-based development feasible for your team?
Yes, with the supporting practices below. The model scales in two forms, according to the trunkbaseddevelopment.com site: very small teams may commit directly to the trunk, while larger teams use short-lived branches reviewed through pull requests before merging. It also expects automated tests that run on every change; DORA calls trunk-based development a required practice for continuous integration, which is the combination of frequent merges with a fast automated test suite.
It fits poorly when releases are tied to a long manual QA cycle you cannot automate, or when the team cannot keep the build green. Those are the problems to fix first. The same site says teams also need a build server to verify that commits have not broken the build once they land.
Feature toggles (flags) keep unfinished work off
If you merge daily, you will merge code that is not finished. A feature flag lets that code reach the trunk and production while staying switched off. The feature flags page on the same site describes flags as a standard way to control capabilities, at the size of a whole component or something small. A minimal C# example, using an environment variable as the flag source:
var config = new ConfigurationBuilder()
.AddEnvironmentVariables()
.Build();
// Features__DiscountCode=true turns it on (double underscore maps to ":")
bool.TryParse(config["Features:DiscountCode"], out bool discountEnabled);
decimal total = 100m;
if (discountEnabled)
{
total = ApplyDiscount(total); // merged to trunk, dark until the flag is on
}
Console.WriteLine($"Total: {total}");
static decimal ApplyDiscount(decimal amount) => amount * 0.9m;
Compiled with Microsoft.Extensions.Configuration.EnvironmentVariables 10.0.0 and run twice. Without the variable the output was Total: 100. With Features__DiscountCode=true it was Total: 90.0. The new code is in the trunk in both runs, but only one of them uses it. Flags are temporary: remove the flag and the old path after the rollout, or the code accumulates dead branches. More on flag hygiene in feature toggle best practices.
For a change too big for one flag, the same site describes branch by abstraction: put an abstraction in front of the old code, build the new implementation behind it in small commits on the trunk, then switch over.
Benefits of trunk-based development
- Smaller merges. DORA says fewer development lines and small, frequent merges reduce the complexity of merge events.
- Earlier feedback. Others see your work the same day, and CI tests the integrated result.
- Releasable trunk. If every merge is production-ready, a release is a decision, not a project.
- No integration phase. There is less need for code freezes and stabilization weeks.
These benefits depend on the practices below. Merging daily without tests mostly moves the pain into production. No figures are claimed here for your team; measure your own lead time and failed-change rate before and after.
Best practices of trunk-based development
Develop on the trunk (master)
Treat the trunk as the only long-lived development line. Everyone starts from it and returns to it. Pull the latest trunk before starting and again before merging, so your change is tested against what everybody else just merged.
Keep the feature branch life short
The old rule of thumb on this page was one to three days. The sources are stricter: DORA describes branches that last no more than a few hours, and the short-lived feature branches page counts time spent waiting for review toward the branch’s life. Pick a limit you can enforce, such as merging within a working day, and treat anything older as a signal to split the work or hide it behind a flag.
Create feature branches from the trunk
Branch from the current trunk, never from another feature branch. Stacked branches recreate the long-lived branch problem one level down.
git switch main
git pull --ff-only
git switch -c add-discount-flag
Align branches with a small story or task
One branch, one small change that a reviewer can read in minutes. If a story needs a week, split it into steps that each leave the trunk working, for example: add the flag, add the data model, add the endpoint, then switch the flag on.
Clean merges to the trunk
Before merging, fetch, rebase onto the trunk and fast-forward. This keeps history linear and shows exactly what you changed. This sequence was run in a scratch repository with a local bare remote (Git 2.50.1):
git fetch origin
git rebase origin/main # Current branch add-discount-flag is up to date.
git switch main
git merge --ff-only add-discount-flag
git push origin main
git branch -d add-discount-flag
The merge fast-forwarded (Updating 2ab3a57..7446bc8, Fast-forward), the branch was deleted, and the log showed a straight line: 7446bc8 Add discount code behind flag, off by default on top of 2ab3a57 Initial app. A squash merge in your hosting tool gives the same linear result.
Do not commit to the trunk directly (unless your team is tiny)
The old advice here was an absolute rule. The more accurate version: the trunkbaseddevelopment.com site says very small teams may commit directly, and that short-lived branches with review are used as teams grow. Whichever you choose, protect the trunk so nobody pushes unreviewed or failing code. On GitHub, protected branch rules can require pull request reviews and passing status checks before merging.
Merge from a feature branch to the trunk
Short-lived branches flow into the trunk. Do not make the trunk depend on another long-lived branch, and do not merge a release branch back wholesale. Updating your own branch from the trunk (rebase or merge) is fine.
Every merge should be production-ready
Production-ready here means the build passes, tests pass and unfinished work is behind a flag. It does not mean the feature is visible to users. Run the full build and tests locally before pushing, and again in CI. The sources describe doing a full pre-integration build on the developer’s workstation first.
Keep the trunk green
A red trunk blocks everyone. DORA says developers are responsible for keeping the build green and must stop what they are doing when CI fails. If the fix is not obvious, many teams revert the change first, which unblocks everyone sooner than a broken trunk. Make CI fast: slow pipelines push people toward bigger, rarer merges.
Avoid merging release branches back to the trunk wholesale
Release branches are optional. Per the DORA description, they are snapshots cut from the trunk, and fixes are made on the trunk first and cherry-picked into the release. Teams that release several times a day need no release branch at all and fix forward. The flow is one way: from the trunk to the release, by cherry-pick. This was run on the same scratch repository:
git switch -c release/1.0 main # cut the release from the trunk
git switch main
# ...commit "Fix typo in checkout message" on main (dbc9801)...
git switch release/1.0
git cherry-pick -x dbc9801 # bring the fix into the release
The graph afterwards showed dbc9801 on main and the copied commit ae24a21 on release/1.0, and -x records the original commit id in the message. For cherry-pick details in different tools see cherry-pick in Git, Azure DevOps, GitLab and GitHub and cherry-pick in GitHub step by step.
Common problems and what was tested
- Branches live longer than planned. Split the work, or put the unfinished part behind a flag and merge it.
- Merge conflicts every day. Merge more often and keep changes smaller; large formatting changes should go in on their own.
- A broken trunk. Revert, then fix. Require status checks before merge.
- Flags pile up. Give each flag an owner and a removal date.
- Tested: the Git commands (Git 2.50.1, local bare remote) and the C# flag example (.NET SDK 10.0.401). Not tested: any hosted Git service, branch protection settings, merge queues, large teams or monorepos. Practice descriptions rely on the linked DORA and trunkbaseddevelopment.com pages, read on 24 November 2026.
Summary
- Merge small changes into one trunk at least daily; keep branches short-lived (hours, per DORA).
- Use flags for unfinished work and branch by abstraction for big changes.
- Protect the trunk: reviews and passing checks before merge; revert if it turns red.
- Release from the trunk, or cut short-lived release branches and cherry-pick fixes into them.
Further reading: Trunk-based development (DORA), trunkbaseddevelopment.com and About protected branches (GitHub Docs).
Found this useful?
Bookmark this page and share it with your team. Get new .NET, cloud and database tutorials in your inbox.
FAQ
What is trunk-based development?
A branching strategy where developers merge small changes into a single shared branch, the trunk or main, at least once a day, instead of keeping long-lived feature branches. Any branches that exist are short-lived, and unfinished work is hidden behind feature flags.
How long should a branch live in trunk-based development?
DORA describes branches that typically last no more than a few hours, and trunkbaseddevelopment.com counts review waiting time as part of the branch life. A practical limit is to merge within one working day; older branches should be split or put behind a flag.
Do you need release branches with trunk-based development?
Not always. Teams that release several times a day can release straight from the trunk and fix forward. Others cut a short-lived release branch from the trunk and cherry-pick fixes into it from the trunk, and do not merge it back wholesale.

Nicely explained! . Can you please explain on how to manage multiple releases? I am sure feature toggle alone won’t solve the problem. Any inputs would be helpful.
Thanks Swapnil for your comments.There are challenges around the same but one should follow best practices around managing your feature toggle. Feature toggles are always temporary..they should be removed once after every featuresbeing released.