Skip to navigation

Claude Code Hotfix Backports: Cherry-Pick Carefully

In short: Start from the supported release tag, apply the smallest fix, resolve conflicts, and record the source commit and test scope.

Published 18 min read
On this page

Direct answer

Treat a backport as a new integration, not a copy of a fix. Start from the supported release tag, review the source diff, cherry-pick the smallest unit that fixes the defect, resolve conflicts against the release branch’s own context, and rerun the checks that apply to that branch. The Git cherry-pick documentation points to the merge documentation for conflict-resolution guidance, which is the honest signal that a cherry-pick can conflict and needs the same care as a merge (F079). A clean cherry-pick proves the patch applied, not that the behavior is identical on the older codebase.

Record the source commit, the release base, what differed, and the test scope for every backport (F081). That record is what lets a reviewer trust the release two months later.

Evidence map linking a source hotfix commit to a backport commit on a release base and the test scope that verifies it.
Editorial evidence map based on F079, F080, and F081. It organizes the backport record; it is not a guarantee that the patch behaves identically on the release branch.

Why backports break quietly

The danger with a backport is not the patch. The danger is the assumption that the older release branch is the same program. Between the mainline and a supported release branch, other changes have landed, dependencies have drifted, and callers may use the older API differently.

A hotfix that works on main can behave differently downstream for reasons that have nothing to do with Git. A function the patch calls may have a different signature on the release branch. A default value the patch relies on may not exist yet. A caller that was removed on main may still be present and reachable on the release branch, and the fix can change that caller’s behavior in a way nobody tested.

This is why the source diff must be reviewed before the cherry-pick, not after (guardrail). Reading the diff tells you what the fix depends on. The cherry-pick only tells you whether it applied.

Choose the supported release base

Start from the tag or branch that is actually supported, not from a guess about what production runs. The release base determines which consumers receive the fix and which compatibility rules apply.

Confirm the exact commit or tag the hotfix will land on. A tag names a revision, and the release process that created it is described in annotated release tags. If several release lines are supported, each line is a separate backport decision. The Git documentation supports tagging specific commits, which lets a release line have a stable identity independent of any moving branch (F089).

Supported line Base to confirm Consumers receiving the fix Fix transport
2.4.x Tag v2.4.3 on branch release/2.4 Users pinned to 2.4 Backport commit plus v2.4.4 tag
3.0.x Tag v3.0.1 on branch release/3.0 Users pinned to 3.0 Separate backport commit
main Current main HEAD Unreleased consumers Fix already landed, or merge forward

A fix does not propagate automatically to every supported branch. Each branch needs its own backport, its own tests, and its own release (guardrail). Treating one backport as coverage for all lines is how a “patched” vulnerability stays reachable on an older line.

Inspect the source fix and tests

Before touching the release branch, read the source change. Look for three things: what behavior changes, which tests cover it, and what the fix assumes about its surroundings.

A source commit that bundles a fix with a refactor or a dependency bump is a poor backport candidate. The refactor may not apply, and the dependency bump may be inappropriate for an older supported line. Prefer a source commit that is small and single-purpose, which is the same discipline as atomic commits that stay revertible.

Tests that came with the fix are the strongest part of the backport, because they define what “fixed” means. Carry them across unless the release branch’s test harness cannot express them. If a test has to be adapted, that adaptation is a semantic decision to record, not a mechanical step.

Source commit Changed behavior Included tests Release-base difference
f10a2b3 Rejects empty region with a clear error 3 unit tests, 1 contract test Release branch still has a caller passing empty region
c4d5e6f Bounds a retry loop to prevent a tight spin 2 unit tests Release branch uses an older retry helper
a7b8c9d Removes an unused parameter 0 tests Refactor, not a fix

The last row is the trap. A commit with no tests and no behavior change is cleanup, and cleanup does not belong in a hotfix (guardrail). Leaving it on main is the correct outcome.

Separate required changes from cleanup

A hotfix should carry the smallest unit that fixes the defect. Everything else waits for the normal release train.

The split is not always obvious, because a fix sometimes depends on a helper that only exists on main. When that happens, the helper is a required change and belongs in the backport. A nearby rename that the fix does not need is cleanup and stays behind. Making this call explicitly is what keeps the release diff reviewable.

A pragmatic test: if the release branch would build and pass its relevant checks with only the fix and its required dependencies, that set is the backport. Any hunk that is not required to fix the defect is excluded.

Cherry-pick the smallest unit

With the base confirmed and the source diff reviewed, apply the change. The cherry-pick command takes the source commit and applies its diff onto the current branch. Where the release branch differs, the apply can stop and ask for resolution.

The Git documentation for cherry-pick refers to the merge documentation for how to resolve conflicts (F079). That reference is the useful one, because a cherry-pick conflict is a merge conflict in miniature: two histories disagree about a region, and a person has to decide which behavior the result should have.

Resolution is a semantic decision, not a text edit. Choosing “take ours” can discard the fix. Choosing “take theirs” can import mainline context that the release branch cannot support. The right resolution is usually a third version that expresses the fix using the release branch’s own helpers.

Backport hunk Conflict Semantic decision Verification
Retry bound in poller.go Helper signature differs Call the release-branch helper with the new bound Release-branch unit test for the bound
Error message in config.ts Text differs between branches Keep the fix’s clearer text Consumer-visible text contract check
New guard in validate No conflict Apply as-is Existing validation suite

The error-message row is a compatibility question in disguise. If consumers parse that text, changing it is a breaking change on the release branch too, and the fix may need a different shape there. The classification method is covered in deciding a major, minor, or patch increment.

Resolve context and semantic differences

After the mechanical conflicts are resolved, look for the differences that produce no conflict and no error. These are the expensive ones.

A function the patch calls may exist on both branches with different behavior. A caller the patch affects may have different reachability. A default the patch assumes may be absent. None of that conflicts, so Git applies the patch cleanly and the divergence survives.

The check is to ask what the fix assumes and verify each assumption on the release branch. Where an assumption fails, adapt the fix rather than the branch. Adapting the branch to suit the fix is how a hotfix turns into an unplanned upgrade.

Workflow from confirming the release base to cherry-picking, resolving semantic differences, and running release-branch checks.
Editorial workflow based on F079 and F081. The sequence describes an integration review method, not an official Claude Code procedure or a conflict-free guarantee.

Run release-branch checks

A backport is verified on the branch it lands on. The mainline test run does not transfer.

Pick the checks that cover the changed behavior plus the checks the release branch normally gates on. A full matrix may be unnecessary for a one-file fix, but skipping the branch’s own gate defeats the purpose of a verified release. The relevant scope is a decision to record (F081).

Test tooling supports scoping. The Jest command line offers options to run only tests matching a pattern or related to changed files (Jest CLI options, official). Scoping is a way to get fast feedback during the backport; the release gate still decides whether the branch ships.

Check Scope Why it applies Run on
Unit tests for changed files The fix plus its adapted tests Confirms the fixed behavior on this branch Release branch
Related integration tests Callers reachable on this branch Catches callers that exist only here Release branch
Branch gate (lint, build) Whatever the branch normally requires Matches the branch’s own release bar Release branch
Consumer contract tests The documented API surface Catches compatibility drift from the fix Release branch

When a check cannot run on the release branch, that is a gap to record rather than a box to tick. Triaging flaky tests before rerunning matters here, because rerunning a flaky test until it passes is not verification.

Record source and backport commits

Close the backport by writing the chain down. The record connects the original fix to the branch that received it and the verification that applies.

Source commit Backport commit Tag Test scope Follow-up
f10a2b3 on main b21c3d4 on release/2.4 v2.4.4 Unit, integration, gate None; main already fixed
f10a2b3 on main e5f6a7b on release/3.0 v3.0.2 Unit, gate; integration skipped, recorded Add release-branch integration coverage
c4d5e6f on main c9d0e1f on release/2.4 v2.4.5 Unit, gate Cleanup commit deferred to next minor

This record-keeping is a recommendation, not an automatic Git feature (F081). Nothing in Git creates the link for you. The value shows up when someone later asks which release lines received the fix for a given defect and what was verified on each.

The version class of the backport release is its own decision. SemVer classifies compatible bug fixes as patch changes (F080), and deciding a major, minor, or patch increment covers how to classify from consumer impact.

Decide whether the mainline needs a follow-up

Sometimes the backport changes the fix. If the release branch needed an adaptation, ask whether main has the same latent problem. A fix that had to be reshaped for an older API can reveal a cleaner shape that main should adopt.

Record the follow-up as a linked item, not a mental note. A follow-up with an owner and a reason is the difference between a backport that improves the codebase and one that leaves main with a weaker version of the same fix.

This is also the moment to check the inverse direction. If the fix never landed on main, a backport is the wrong transport and the change should merge forward instead. The forward path is the normal one, and the backport exists for consumers pinned to a released line.

Tradeoff between a minimal backport that ships fast and the residual risk of unverified semantic differences.
Editorial tradeoff diagram based on F079 and F081. A minimal backport reduces review surface but leaves semantic divergence as the risk a reviewer must chase.

Ask Claude Code to compare the source and the backport

After the backport lands, ask Claude Code to compare the two commits. A useful prompt names both and asks for the differences that matter:

Source fix is f10a2b3 on main and the backport is b21c3d4 on release/2.4. List every functional difference between the two diffs. For each, say whether it changes behavior on the release branch or only adapts to a different helper.

Review the answer for adaptations that are actually behavior changes. A renamed helper is safe. A removed call the patch no longer makes may be a behavior change the release branch’s callers depended on. Claude Code can surface the diff, and a person who knows the release branch’s consumers owns the judgment.

The comparison is also where Claude Code can catch a hunk that slipped in. If the backport carries a rename that the fix does not need, that is cleanup in a hotfix (guardrail), and the reviewer should ask for it to be dropped.

Worked example: backporting a retry bound

Suppose main has a fix that bounds a retry loop in poller.go so a failing endpoint cannot spin. The source commit c4d5e6f includes two unit tests. The supported release line is 2.4, currently at tag v2.4.3.

Base check: release/2.4 is checked out at the commit v2.4.3 points to. Tree is clean.

Source review: the fix calls a helper withBackoff(fn, max) that exists on main. On the release branch, the helper is withBackoff(fn) and takes no bound. The fix also removes a debug log line that only exists on main.

Scope decision: the required change is the bound. The helper must be extended or the bound expressed another way. The removed debug line is cleanup and is excluded.

Cherry-pick: applying c4d5e6f onto release/2.4 conflicts in poller.go because the helper call differs.

Resolution: adapt the call to the release-branch helper by adding the bound parameter to that helper, then use the bounded form in poller.go. The debug-line hunk is dropped during resolution.

Verification: run the two carried unit tests plus the release-branch retry suite and the branch gate. All pass. Integration coverage for the retry path does not exist on the release branch, and that gap is recorded.

Record: source c4d5e6f, backport c9d0e1f on release/2.4, tag v2.4.5, test scope unit plus gate, follow-up to add release-branch integration coverage.

Derived arithmetic for the patch surface: the source commit touches 4 hunks across 2 files. After dropping the debug-line hunk, the backport applies 3 hunks. Required-hunk ratio = 3 / 4 = 0.75. This arithmetic describes how much of the source change was needed; it is not a risk score or a quality measure.

The concrete win is that users pinned to 2.4 receive the retry bound without an upgrade to a newer major, and the record shows exactly what was verified on their branch. The concrete loss is that the helper had to change shape, so the release-branch fix is not byte-identical to the mainline fix, and the missing integration coverage means a caller reachable only on 2.4 is unverified.

Control checklist covering release base confirmation, source review, minimal cherry-pick, semantic resolution, and test scope.
Editorial control checklist derived from F079, F080, and F081. Passing the checklist makes the backport reviewable; it does not prove behavior is identical to main.

Practical checklist and runbook

Use this sequence for every backport. It keeps the source link and the verification scope attached to the change.

  1. Confirm the supported base. Name the tag or commit the fix will land on.
  2. Review the source diff. Identify behavior, tests, and assumptions before applying.
  3. Split fix from cleanup. Carry the smallest unit that fixes the defect.
  4. Cherry-pick onto the release branch. Expect conflicts where the branch differs.
  5. Resolve semantically. Express the fix with the release branch’s own helpers.
  6. Check silent divergences. Verify each assumption the fix makes about its surroundings.
  7. Run release-branch checks. Cover the changed behavior plus the branch gate.
  8. Record the chain. Source commit, backport commit, tag, test scope, gaps.
  9. Tag a new release. Do not rewrite the published release tag.
  10. Decide on follow-ups. Link any adaptation main should adopt.
Gate Pass condition Failure response
Base confirmed Exact supported commit is named Identify the supported line first
Source reviewed Behavior, tests, and assumptions are listed Read the diff before applying
Minimal unit Every hunk is required to fix the defect Drop cleanup hunks
Conflicts resolved semantically Result uses release-branch helpers correctly Rework the resolution
Checks run on branch Changed behavior and gate pass on release base Rerun on the branch, not main
Chain recorded Source, backport, tag, and scope are written Add the missing record

The practical implication is that a backport is cheap to apply and expensive to trust without a record. Writing the chain takes minutes and answers the audit question that otherwise requires archaeology.

Verdict that a reviewed and recorded backport is trustworthy for a supported line while semantic divergence remains the open risk.
Editorial verdict based on F079, F080, and F081. The benefit is a traceable fix on a supported line; the unresolved risk is silent divergence that no conflict surfaced.

Concrete win, honest loss, and next decision

Win: In the retry-bound example, users pinned to 2.4 got the fix as v2.4.5 without a major upgrade, and the record shows the source commit, the adapted helper, the tests that ran, and the follow-up for missing integration coverage.

Loss: The release-branch fix is an adaptation, not a copy. It changed the release branch’s helper signature, so the two fixes are functionally equivalent by intent but not identical by construction. Nothing in Git verifies that equivalence, and the missing integration test leaves one caller unverified on that branch.

Implication: Use careful backports for supported release lines with pinned consumers, especially for security and data-integrity defects. For an internal service with a single deployable HEAD, a forward fix is usually simpler and a backport adds process without adding safety.

Connect the backport to the rest of the batch

A backport sits between two release disciplines. Deciding the major, minor, or patch increment classifies the backport release, and annotated release tags pins the base the fix lands on without rewriting a published tag.

Planning a revert before release is the inverse operation, and consumer-facing changelog entries tell users what the backport fixed and whether they must act. Verifying the release candidate is the single record that ties the backport to identity, tests, and rollback.

For the underlying commits, atomic commits that stay revertible and commit messages that encode change intent make a source fix easier to backport cleanly. Resolving merge conflicts by behavior is the same resolution discipline at merge scale, and choosing a rebase or merge policy explains when history should be replayed at all.

Test evidence for the backport comes from mapping changed code to checks and contract tests for API expectations. Triaging flaky tests before rerunning keeps a rerun from standing in for verification, and isolation with test fixtures matters when the release branch’s shared state differs.

When a backport fails in the field, hunting the regression with git bisect locates the change that misbehaved, and false success from passing tests explains why a green run on main said nothing about the release branch. Guardrails against destructive git reset protects the branch while you work.

For release mechanics around the backport, see defining branch protection merge checks and recovering failed merge-queue groups. For stashing unrelated local work before cherry-picking, see recovering stashed work without dropping it. When the backport must be handed to another maintainer, session handoff with team context carries the record.

Data gap and future update

The Git documentation confirms that cherry-pick refers to merge documentation for conflict resolution (F079), that tags can target specific commits (F089), and that SemVer classifies compatible fixes as patches (F080). None of the cited sources provides a measured rate of failed backports, a benchmark comparing cherry-pick with manual patching, or data on how often a clean apply diverges semantically. No such figure is claimed.

The backport record is a recommendation, not a Git feature (F081), so its value depends on team discipline and cannot be measured from the sources here. A future update could add a template teams publish if one becomes available.

Rolling documentation can change. Recheck the cited Git and Jest pages before relying on specific option wording, and keep the caveats if the text shifts. Until measured evidence exists, treat this sequence as a reviewable integration practice rather than a proven reduction in backport incidents.

One AI API Key option for OpenAI-format agents

Claude Code uses an Anthropic-format route, so the One AI free model IDs are not a Claude Code model source. The packet records Claude IDs as unavailable on 2026-11-27.

For a separate OpenAI-format agent, One AI API Key provides https://api.oneaiapikey.com/v1, one key, and 46 live free IDs. That option concerns a different client and request format, not a workaround for Claude Code authentication. Check the free model list and eligibility details before choosing an agent route.

FAQ

Does a clean cherry-pick mean the fix works on the release branch?

No. A clean apply means the patch fit the text. Behavior depends on helpers, callers, and defaults that may differ on the release branch. Those divergences often produce no conflict at all, so only running the release-branch checks and reviewing assumptions establishes the behavior (F079).

Should the tests from the source commit be backported too?

Usually yes, because they define what fixed means. If the release branch’s harness cannot express them, adapt them and record the adaptation as a semantic decision. A backport with no tests is a patch whose success rests entirely on manual review.

Can one backport cover every supported release line?

No. Each supported line is a separate integration with its own base, its own conflicts, and its own tests (guardrail). A fix that is correct on one line can require a different shape on another, so cover them one at a time.

What version increment does a backport get?

A compatible bug fix is a patch increment (F080). If the backport changes behavior in a way consumers must react to on that line, classify it by observed impact instead, using the same method as any other release.

Can I fix the release branch by merging main into it?

Bringing main into a release branch would carry every other mainline change, which defeats the point of a supported line. Cherry-pick the specific fix. The rebase-versus-merge tradeoffs are covered in choosing a rebase or merge policy.

More Claude Code troubleshooting

Sources

  • Official: Git cherry-pick, supporting the reference to merge conflict-resolution guidance (F079).
  • Official: Git tag, supporting tagging specific commits so a release line has a stable identity (F089 context).
  • Official: Git rebase, supporting the distinction between replaying history and applying a single change.
  • Official: Git log, supporting inspection of the source fix and its history.
  • Official: Semantic Versioning 2.0.0, supporting the patch classification for compatible bug fixes (F080).
  • Official: Jest CLI options, supporting scoped test runs during backport verification.
More in Blog

Try it

One API key for GPT, Grok, DeepSeek, Kimi, GLM, MiniMax, Qwen, Step, Beam, Nemotron, ERNIE, Hunyuan, Gemma, Laguna, LFM, LongCat, Llama, Solar, Jais, Mistral, K2 and Roleplay.

One AI API Key speaks the OpenAI and Anthropic formats, so you change the base URL and the key, not your code. Credit packs start at $10, and every model has a published per-token rate.

New accounts$10 credit on sign-up
  • 100requests
    per day
  • 3Mtokens
    per day
  • 47free
    models
  • $0per
    token
  • No card
  • No end date
Claim $10 credit →