AniSri

A gitflow branching strategy for a release-managed codebase

Four build files share one version string. The pre-release marker comes off before anything hits pre-prod. The release branch is built and verified ahead of the change window, so the window is a promotion of an artifact that already exists. Almost none of this is enforced by tooling. It still depends on someone reading the wiki correctly, twice, every release.

Insights Release engineering Published December 2023 Edit Assist: AniBot powered by Claude

The shape of it

Two branches are protected and nobody commits to them directly: main, which only holds what is approved for production and is the only branch prod deploys from, and develop, where finished features land before they become a release candidate. Everything else is disposable. feature/* carries work in progress. release/* carries a numbered candidate through its final checks. hotfix/* carries an urgent fix to what is already running. All three get deleted when their job is done. The permanent record lives in merge history and tags, not in a long-lived branch name.

This is Vincent Driessen's 2010 gitflow model, close to unchanged, and still common on release-managed estates. Whether it is the right call depends on fit. Gitflow earns its ceremony when releases are coordinated across teams and gated outside git: a change advisory board, a fixed deployment window, a regulatory sign-off. Trunk-based development with feature flags is faster when the team can deploy the moment code merges. Driessen made the same point himself in a 2020 note on the original post: teams that deliver continuously should pick something simpler, like GitHub flow. The tell is in the workflow itself. A release branch sits built and verified in pre-prod, waiting for a change window, because the team cannot ship on merge. Teams that can, skip this step.

One release, step by step

Three engineers, three feature branches, all cut from the same develop and landing back on it at different times, then one release branch that carries the lot to production. Step through it, or let it play.

release 2.4.0, three devs
main release/2.4.0 develop R M W tag / prod
Gitflow branch diagram: three feature branches merge into develop, a release branch is cut and verified through pre-prod, merged to main with a tag, deployed to prod from that tag, then merged back into develop. main release/2.4.0 develop feature/checkout-timeout feature/webhook-retry feature/notif-batching CHG window v2.3.0 2.4.0-dev 2.4.0 2.5.0-dev app:2.4.0 v2.4.0 deleted
  1. app:2.4.0
  2. build
  3. dev
  4. test
  5. uat
  6. pre-prod
  7. prod
The whole release
Branch, merge, cut, verify, promote, record

R, M and W branch off develop, commit at their own pace and merge back when done. One CI job cuts release/2.4.0, strips the pre-release marker and bumps develop to 2.5.0-dev. app:2.4.0 is built once and climbs to pre-prod before any change window exists. Once pre-prod signs off, release/2.4.0 merges to main and is tagged v2.4.0. In the window, prod deploys from that tag. The release branch merges back into develop and is deleted.

The version string is the environment gate, if something checks it

The rule has two halves. Pre-prod only accepts a build from a release/* or hotfix/* branch, on a release version with no pre-release marker. Production only deploys from a release tag on main, and only an artifact pre-prod already verified. Every packaging ecosystem draws the same line, it just spells it differently. A pre-release version is a moving name: it points at whatever was built last, which is exactly what you want while a feature is still moving. A release version is meant to be fixed, one name for one artifact.

But "meant to be" is doing the work in that sentence. Nothing in mvn deploy, npm publish, twine upload or docker push knows which branch it was run from, and a deploy job will ship a pre-release build without complaint unless something in the path refuses. The version format defines the convention. Something else has to enforce it.

same idea, different spelling
movingfixedwhat stops a fixed version changing
Maven / Gradle2.5.0-SNAPSHOT2.4.0Release repository in Nexus or Artifactory with redeploy disabled
npm2.5.0-dev.172.4.0The registry never lets a published version be overwritten
Python2.5.0.dev172.4.0The index refuses re-uploads, and pip skips pre-releases unless asked
Container image:develop, :latest@sha256:…Digests are content-addressed. Tags need registry tag immutability

The rest of this piece writes the moving version as 2.5.0-dev. Read it as whichever spelling your stack uses.

Three good places to enforce it, and you want at least two:

layer 1 · repository
Release store refuses moving versions Release artifacts go to a store that only takes release versions and never overwrites one: a release-only repository, a package index, a registry with immutable tags. Once 2.4.0 lands, it stays 2.4.0.
layer 2 · build
Release builds reject pre-release inputs On release/* and hotfix/*, fail the build if the version or any resolved dependency is a pre-release, or a base image is pulled by a moving tag. In Maven that is maven-enforcer-plugin. Elsewhere it is a lockfile check.
layer 3 · pipeline
Guard on every pre-prod and prod job Pre-prod jobs check the branch pattern and version. The prod job refuses anything but a release tag on main, and promotes by digest the image pre-prod verified.
what each environment accepts
devtestuatpre-prodprod
feature/*2.5.0-dev opt-in opt-in opt-in ✕ ✕
develop2.5.0-dev ✓ ✓ ✓ ✕ ✕
release/2.4.02.4.0, one pre-release dependency ✓ ✓ ✓ ✕ deps ✕
release/2.4.02.4.0, clean ✓ ✓ ✓ ✓ via main
hotfix/2.4.12.4.1, clean ✓ ✓ ✓ ✓ via main
maintag v2.4.0 or v2.4.1 n/a n/a n/a n/a ✓ CHG

The dashed line is the gate. Release and hotfix branches prove themselves up to pre-prod, and prod only ever deploys a tag on main. The third row is the one the version string alone misses: the project says 2.4.0, but a dependency still points at a moving version (a SNAPSHOT jar, a -beta package, a :latest base image), so the build is still a moving target. Only the build-time dependency check catches it.

Same rule for images

A tag like app:2.4.0 is a pointer that can be re-pushed unless tag immutability is switched on (ECR, Harbor and Artifactory all support it). Promote by digest and the question goes away.

Four build files, one human keeping them in sync

Here is the part of the model that is still running on discipline instead of tooling. Four separate build files need the same version string (on the estate this came from, four Maven poms; it could as easily be package.json files in a workspace, pyproject.toml, or a Chart.yaml next to the app it deploys), and the source document says it plainly: get it wrong and you will get a build error. That sentence, in bold, on a wiki page, is a documented failure mode being handled by asking someone to read carefully at the exact moment they are least likely to, mid-release, under a deadline.

If these modules ship together, this should never be a four-file manual edit. The version lives in one place, everything else inherits or reads it, and the bump is a single command a CI job runs. Every mainstream build tool has one.

The wiki also runs that bump in the wrong place. It moves the version forward each time a feature branch is created. With three features in flight, that is three branches editing the same four lines, and every merge after the first conflicts on the build files for no gain. Features do not need their own version. They inherit develop's. The bump belongs in exactly one job, the one that cuts the release:

# on the new release/2.4.0 branch, then 2.5.0-dev on develop, same job

# Maven: parent pom holds it, every module follows
mvn versions:set -DnewVersion=2.4.0 -DprocessAllModules=true -DgenerateBackupPoms=false

# npm workspaces
npm version 2.4.0 --workspaces --include-workspace-root --no-git-tag-version

# Python (Poetry)
poetry version 2.4.0

Lighter still: derive the version from the git tag at build time, so no commit edits a version at all. Maven's CI-friendly ${revision}, setuptools-scm for Python and a git describe step for image tags all do this. If the four build files do not belong to one product, if they are independent artifacts that happen to need matching versions, that is a structural smell worth naming on its own, not a versioning problem to work around.

Starting and finishing a feature

feature branch lifecycle
BranchCut from develop, named by ticket or intent. Version untouched.
Build & testCI runs unit and integration tests on every push.
Deploy, if askedReaches dev, test or UAT only with DEPLOY_FEATURE_BRANCHES=true.
MergeReviewed PR into develop, once it is current with develop.
DeleteIts job is done. Merge history keeps the record.

The default worth keeping is step three: a feature/* branch reaches no real environment unless someone deliberately sets DEPLOY_FEATURE_BRANCHES=true for that run. In-progress work is invisible everywhere by default. Visibility is opt-in, not something you have to remember to prevent. When a feature needs UAT sign-off before it merges, that flag is how it gets there, one run at a time.

The release branch and the pre-prod head start

Building the release branch all the way to pre-prod before the change window opens is the best operational call in this model, and it is easy to miss why. By the time the CHG record exists, the image is already in the production registry. The window itself is a promotion of an already-built, already-verified artifact, not a build-and-deploy race against a change board clock. If the CHG slips a day, nothing is lost. The artifact waits.

Compare that to building inside the window. Compile failures, flaky integration tests and slow dependency pulls now happen inside the one hour you got approved for. Front-load the expensive, failure-prone work into a low-stakes rehearsal and leave the cheap, fast promotion for the window. That idea holds even if you dislike gitflow as a branching model.

Two consequences follow. If pre-prod turns up a bug, the fix goes on the release branch and the build gets a new number, because a published release version cannot be rebuilt in place. That is the gate doing its job, not getting in the way. And main moves before the window, not after. Once pre-prod signs off, the release branch merges to main, the merge commit is tagged, and prod deploys from that tag and nothing else. The CHG references the tag, so what was approved and what ships are the same commit by construction.

Deploying from main does not mean rebuilding from main. main only ever receives release and hotfix merges, so the tagged merge commit has exactly the same source tree as the release tip that was built and verified. The prod job checks that match and promotes the existing digest. If the deploy has to be rolled back, the rollback is the previous tag. After the window the release branch merges back into develop so its fixes are not lost, and is deleted.

Redeploying and rolling back by tag

Because prod only ever deploys a release tag on main, every tag on main is a known-good deploy target, and the prod job does not care whether the tag is new. It takes one input, RELEASE_TAG, which defaults to the newest tag on main. A release, a rollback and a plain redeploy are the same job with a different tag.

what is in prod, tag by tag
Redeploy timeline: v2.3.0 runs in prod, v2.4.0 is deployed and has an incident, prod is redeployed to the v2.3.0 tag without a rebuild while main stays at v2.4.0, then v2.4.1 ships forward from main. main in prod RELEASE_TAG=v2.3.0, no rebuild v2.3.0 v2.4.0 v2.4.1 main stays at v2.4.0 v2.3.0 v2.4.0 ✕ incident v2.3.0 again v2.4.1

Same color, same artifact. The rollback puts the exact v2.3.0 digest back into prod. main never moves backwards: the fix ships forward as v2.4.1, and prod catches up with main again.

The prod job resolves the tag to the image digest recorded when that release was built, then deploys the digest. Nothing is rebuilt, so a rollback puts back the exact bytes that ran before, not a fresh build of old source against today's base image and dependencies. The checks are a few lines in any pipeline:

# fetch tags; the newest release on main is the default target
git fetch origin --tags
git describe --tags --abbrev=0 --match 'v*' origin/main

# every redeploy target, newest first
git tag --list 'v*' --sort=-v:refname

# guard: only a tag on main may reach prod
git merge-base --is-ancestor v2.3.0 origin/main && echo "v2.3.0 is on main"

# the artifact behind the tag, no rebuild (registry with immutable tags)
crane digest registry.example.com/app:2.3.0

# then: run promote-to-prod with RELEASE_TAG=v2.3.0
Tags never moveProtect v* tags so nobody can delete or re-point one (GitHub rulesets and GitLab protected tags both do this). Redeploying v2.3.0 only means something if v2.3.0 is the same commit it was last month.
main does not move backwardsRolling prod back to v2.3.0 leaves main at v2.4.0. Do not revert main to match. The fix goes forward as a hotfix cut from the v2.4.0 tag. Until it ships, the deploy record, not main, says what is running.
Code rolls back, data does notRedeploying v2.3.0 is only safe if v2.4.0's schema and data changes still work with v2.3.0's code. Ship migrations expand first, and remove the old shape a release later, so the previous tag is always a valid target.
A rollback is still a changeIt runs the same promote preset and guard, with the CHG or emergency change naming the tag. It is fast because nothing has to be built or verified again, not because it skips the gate.

What the wiki leaves out: hotfixes

Rolling back buys time. The fix still has to ship. Production breaks on v2.4.0, and develop is already on 2.5.0-dev with half-finished work in it, so shipping develop is not an option, and the model as written has no other path. Gitflow's answer is a hotfix/* branch cut from the tag on main. It is a release from birth: version 2.4.1, no pre-release marker, so the same gate admits it to pre-prod. Once verified it merges to main with its own tag, prod deploys from that tag, and it merges into develop, or into the open release/* branch if there is one, which carries it to develop later.

hotfix/2.4.1
Hotfix diagram: hotfix/2.4.1 branches from the v2.4.0 tag on main, gets a fix, is verified, merges to main tagged v2.4.1, and merges into develop. main hotfix/2.4.1 develop v2.4.0 2.5.0-dev work in flight, not shippable 2.4.1 fix verify → pre-prod v2.4.1 or into release/* if one is open

The hotfix never touches develop's unreleased work on the way out. Prod deploys it from the v2.4.1 tag on main, and it reaches develop only by merge.

The pipeline guard has to know about this too. If it only matches release/*, the first real hotfix either gets blocked at the gate or, worse, someone disables the guard for one run to get it through.

Where the human is still the control plane

The part that has not caught up is the pipeline run screen. Getting a release to pre-prod, then to production, means setting eight to ten independent booleans by hand, in the right combination, twice: once for pre-prod with production stages held false, then again for cutover with a different set flipped. That is a checklist wearing pipeline clothes, and checklists fail when people are tired, rushed, or new.

Get one boolean wrong and the failure modes are not symmetric. Skip a test stage silently and you find out later, expensively. Flip a production deploy flag on the wrong run and an unverified build ships. The version gate only catches the pre-release case. It does nothing if someone runs the correct release branch with the wrong stages enabled.

Two fixes, neither exotic. Collapse the boolean matrix into named presets, so a human picks one action instead of ten switches. And put the hard rule into a pipeline guard that runs under both presets and fails fast on its own.

ten switches, two presets (stage names illustrative)
today: set by hand, per run build-and-verify-to-preprod promote-to-prod
BUILD
UNIT_TESTS
INTEGRATION_TESTS
PUBLISH_IMAGE
DEPLOY_DEV
DEPLOY_TEST
DEPLOY_UAT
DEPLOY_PREPROD
DEPLOY_PROD
SMOKE_PROD
RELEASE_TAGn/av2.4.0
guard: no pre-release version or dependency, andrelease/* or hotfix/*release tag on main

Each column is one fixed combination. The person running the release picks a column, the pipeline sets the switches. The promote preset builds nothing: it takes a release tag on main (the newest one unless told otherwise) and deploys the digest behind it. A rollback is the same preset with an older tag.

The version gate and the pipeline guard should both hold independently. If the release store is not set to refuse moving versions, then in the model as written neither of them is enforced by anything other than a careful reader.

The model, one screen

main
protected
Receives release/* and hotfix/* merges once pre-prod signs off. The only source prod deploys from.
develop
protected
Integration branch, always on the next pre-release (2.5.0-dev). Receives features and back-merges, feeds the next release/*.
feature/*
from develop
Inherits develop's version. Deploys only on opt-in. Deleted after merging back.
release/*
from develop
Pre-release marker stripped in the same job that bumps develop. Built once, verified to pre-prod, merged to main before the CHG.
hotfix/*
from the tag on main
Patch version, never a pre-release. Same gate, same path through main, just shorter.
tag
on main, at the merge
What the CHG references, what prod deploys, and what a rollback redeploys. Protected, never moved.
gate
three layers
Release-only artifact store, build-time dependency check, pipeline guard. The version string is the signal, these are the checks.
after release
main, prod, then develop
Merge to main and tag, prod deploys from the tag, merge back to develop, delete the branch.