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.
- app:2.4.0
- build
- dev
- test
- uat
- pre-prod
- prod
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.
| moving | fixed | what stops a fixed version changing | |
|---|---|---|---|
| Maven / Gradle | 2.5.0-SNAPSHOT | 2.4.0 | Release repository in Nexus or Artifactory with redeploy disabled |
| npm | 2.5.0-dev.17 | 2.4.0 | The registry never lets a published version be overwritten |
| Python | 2.5.0.dev17 | 2.4.0 | The 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:
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.
| dev | test | uat | pre-prod | prod | |
|---|---|---|---|---|---|
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.
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
DEPLOY_FEATURE_BRANCHES=true.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.
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
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.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.
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.
| 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_TAG | n/a | v2.4.0 |
| guard: no pre-release version or dependency, and | release/* 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.