What is a branching strategy, and why does it matter?
BeginnerConceptBranching, versioning & releases
Answer
In one line: A branching strategy is the team's agreed set of rules for how branches are created, named, merged and released in Git — it decides how smoothly code flows from developers to production.
Why it matters:
- Fewer merge conflicts when everyone follows the same rules.
- Clear release process — everyone knows which branch is deployable.
- Works with CI/CD — pipelines trigger based on branches (PRs to main, tags for releases).
- Supports the release style — continuous deployment needs a different strategy from quarterly releases.
Main strategies:
- Trunk-based development — everyone merges small changes into
main(the trunk) at least daily; short-lived branches; feature flags hide unfinished work. Best for CI/CD and frequent releases. - GitHub Flow — create a feature branch from
main, open a PR, review, merge, deploy. Simple and very popular. - GitFlow — long-lived
mainanddevelopbranches plusfeature/*,release/*andhotfix/*branches. Suits scheduled releases and several supported versions, but heavier. - Release branches — cut
release/2.3from main for stabilising a version, while main continues; fixes are cherry-picked.
Common rules regardless of strategy:
- Protect
main: no direct pushes, PR reviews required, CI must pass. - Naming conventions:
feature/login-page,fix/null-pointer,chore/upgrade-node. - Keep branches short-lived to avoid painful merges.
- Delete branches after merging.
Example: a SaaS team uses GitHub Flow: branch → PR with CI → review → merge to main → auto-deploy to staging → production after a smoke test. A mobile app team uses release branches because app store releases are scheduled.
Tip for interviews: say which strategy your team uses and why it fits your release style.