Safeguard
Security Guides•

Should a hotfix branch start from the release tag or from main?

Branch a security hotfix from the tag that is running in production, fix it on main first where you can, and merge the fix back so it is never lost.

Safeguard Security Team
4 min read

Start the hotfix branch from the exact release tag that is running in production, not from main, unless production already is main. That keeps unreviewed feature work out of an urgent fix. Land the same fix on main as well, so the next release does not bring the vulnerability back.

Why the starting point matters

A hotfix has one job: change as little as possible between what customers run today and what they run after the fix. Main usually holds weeks of unreleased work. If you branch from it, your hotfix ships all of that too, and you can no longer say what changed.

The Git project's own workflow notes describe the same idea. They keep a maintenance branch for fixes to a released version, separate from the branch where new features land, and they describe copying that branch to a version named branch when a newer feature release ships so the older release can still receive fixes.

Decision table

Your situationBranch fromWhy
Deploy from main many times a daymainProduction is main, so a small commit is the hotfix
One release line, deployed in batchesThe release tag in productionKeeps unreleased work out
Several supported release linesThe tag of each affected lineEach line needs its own tested fix
Hosted product with a release branchThe release branch headIt matches what was last built

Steps for a tagged release

  1. Identify the exact tag running in production. Check the deployed artifact, not your memory.
  2. Create a branch from that tag, named so people can see its purpose, for example hotfix/2.4.1-input-validation.
  3. Write the smallest fix that closes the problem, plus a test that fails without it.
  4. Run the pipeline you normally run. A hotfix is not a reason to skip the vulnerability scan or the review.
  5. Tag the result with the next patch version and release it.
  6. Open a second change that brings the same fix to main.
git checkout -b hotfix/2.4.1-input-validation v2.4.0
# make the fix and test
git commit -am "Reject oversized path segments"
git tag v2.4.1

Fix on main first when you can

When time allows, fix main first and then copy the commit to the older branch with a cherry-pick. This is called upstream first, and it prevents the classic regression where version 2.4.1 is fixed and 2.5.0 is not. The Linux kernel stable rules require that a fix, or an equivalent, already exist in mainline before it is accepted into a stable tree, for the same reason.

When the situation is urgent and main has diverged too far, fix the old branch first and open the main change within the same working day. Put a link to each change in the other.

Common mistakes

  • Branching from main because it is the default and shipping untested features.
  • Forgetting the forward change, so the next release reintroduces the bug.
  • Building the hotfix on a different toolchain version than the original release.
  • Skipping the tag, which leaves production running a commit nobody can name.

Try it yourself

Click through it at your own pace, or open it full screen. Watch how a gate evaluates the change before merge, which is the check a hotfix branch should still pass.

Safeguard can run dependency scanning and policy gates on every pull request, including the ones on hotfix branches, and its autonomous remediation can open fix PRs when you turn it on (it is off by default). You can try a free scan at gold.safeguard.sh/scan.

Quick check

Can I branch from main if I deploy continuously?

Yes. If every merge to main goes to production, main is the release. Keep the fix small and ship it like any other change.

Do I need a tag if the fix is urgent?

Yes. A tag is how you later prove which code ran in production and which fix it contained.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.