Video in progress

Senior 🌿 Git

Versions 3.2 and 3.3 are running in prod, while `main` has moved on to 3.4. How do you deliver a security fix to all versions?

I make the fix on main where possible, then backport it to each release branch with cherry-pick -x, with separate CI and a tag for each. Or the reverse: make it on the oldest branch and merge upward. What matters is that the team has one direction.

📖 Answer

There are two approaches.

Upstream first (cherry-pick downward):

git switch main && git commit -m "CVE-2026-xxxx: JWT audience tekshiruvi"
git switch release/3.3 && git cherry-pick -x 5d1f0a2
git switch release/3.2 && git cherry-pick -x 5d1f0a2   # a conflict is possible

The fix does not get lost on main, but since the code differs on old branches, a cherry-pick often needs manual adaptation.

Merge up (old → new): the fix is made on release/3.2, then merged 3.2 → 3.3 → main. The history stays connected, and with git branch --contains you can see which versions have it. The downside: with every merge, other small changes flow upward too.

Whichever you pick, the practical points are the same:

  • every release branch should have its own CI pipeline. It is common for the build on an old branch to be broken;
  • a patch tag for each: v3.2.7, v3.3.4;
  • a list in the ticket of which versions it was delivered to. Forgetting a backport is the most common mistake;
  • limit the number of supported versions. Every extra version raises the cost of every fix.