Skip to content

commandGit and releases

Cherry Pick Fix

Cherry-picks a fix commit onto a release branch, resolves conflicts with you and runs the tests there before anything is pushed.

npx workspacetemplates add cherry-pick-fix --tool claude-code

Writes 1 file to .claude/commands/

.claude/commands/cherry-pick-fix.md14 lines · 1.2 KBFile
---
description: Cherry-picks a fix commit onto a release branch, resolves conflicts with you and runs the tests there before anything is pushed.
argument-hint: "<commit hash> <release branch>"
---

Backport a fix. Arguments (commit then target branch): $ARGUMENTS

1. Parse the two values. Run `git show --stat <commit>` and confirm it is a single fix, not a merge. For a merge commit ask which parent to use with -m.
2. Ensure a clean tree with `git status --porcelain`. Fetch, then create `backport/<short-hash>-<branch>` from the target: `git switch -c ... origin/<branch>`.
3. Run `git cherry-pick -x <commit>` so the origin hash is recorded.
4. On conflict, list each file with `git diff --name-only --diff-filter=U`, show both sides and explain what changed on the release branch. Propose a resolution and apply it only for trivial cases; ask about anything that changes behavior.
5. Detect the test command from package.json, Makefile or pyproject and run it. If the fix needs code that does not exist on this branch, say so and stop.

Report the branch name, resolved files and test results. Offer the push command but do not run it. Abort with `git cherry-pick --abort` if the user declines.

What it does

Backporting a bugfix is easy until the release branch has drifted. This command applies the commit on a fresh branch from the release line, explains every conflict and checks that the fix still works in that older code.

The original branches stay untouched. You get a ready branch and a test result, and pushing is left to you.

Example

you › /cherry-pick-fix 9be3f10 release/2.3

agent › Created backport/9be3f10-release-2.3. One conflict in src/auth/session.ts: release/2.3 still uses the old token helper, so I kept its call and applied the expiry check. Tests: 214 passed. Push with: git push -u origin backport/9be3f10-release-2.3

Questions

Does it touch my main branch?
No. All work happens on a new backport branch cut from the release branch.
What if the fix depends on a refactor that is not in the release branch?
It stops and names the missing prerequisite instead of forcing a fake patch.
  • Branch Cleanup

    CommandGit and releases

    Free
  • Changelog Entry

    CommandGit and releases

    Free
  • Commit Message

    CommandGit and releases

    Free
  • Fixup Commits

    CommandGit and releases

    Free