Branching strategies
Trunk-based development
Everyone integrates into main (trunk) at least daily via short-lived branches (hours to a couple of days). Main is always releasable; incomplete features hide behind feature flags; releases are tags (or short release branches cut from main).
- Pros: minimal merge conflicts, true continuous integration, fast feedback, fits continuous delivery and GitOps.
- Needs: strong automated tests, fast CI, feature flags, discipline about small changes.
- Strongly correlated with high delivery performance in the DORA research.
GitFlow
Long-lived main (production) and develop branches, plus feature/*, release/* and hotfix/* branches with prescribed merges between them.
- Pros: structure for versioned, scheduled releases (packaged software, mobile apps, multiple supported versions).
- Cons: heavy, long-lived branches, big merges, slow integration — generally considered a poor fit for web services doing continuous delivery. Even its author later recommended simpler flows for continuously delivered software.
GitHub flow
Branch from main → PR → review + CI → merge → deploy main. Essentially trunk-based with PRs; a sensible default for most service teams.
Release branches
Cut release/1.4 from main when you need to stabilise or maintain a version; fix on main first and cherry-pick to the release branch (or the reverse, but be consistent). Useful for on-prem products or regulated release trains.
Environment branches: an anti-pattern in GitOps
Having dev, staging, prod branches in a GitOps config repo and merging between them tends to cause drift, confusing merges and accidental promotion of unrelated changes. The common recommendation is one branch with a directory per environment (Kustomize overlays: overlays/dev, overlays/prod) and promotion by changing values in the next environment's directory via PR.
Versioning and releases
- Semantic versioning
MAJOR.MINOR.PATCH: breaking change → major, new feature → minor, fix → patch. - Tag releases (
v1.4.0, annotated and ideally signed); CI builds release artifacts from tags. - Automate with Conventional Commits + tools like semantic-release or release-please (generates the changelog and version bump from commit messages).
- Container images: tag with the commit SHA for traceability, plus the semver tag for releases.