Git in a Minute · intermediate

Git in a Minute: Cherry-pick

Cherry-pick copies a commit onto your current branch—useful for rescuing a good agent fix from a messy branch.

Last verified: 2026-09-06

In one sentence

Cherry-pick applies the changes from an existing commit onto your current branch as a new commit.

Why it matters

Agents often produce a useful fix buried in a branch that also contains noise. Cherry-pick lets you keep the good commit without merging the mess.

How it works

git switch main
git switch -c hotfix/from-agent
git cherry-pick <commit-sha>

Resolve conflicts if the surrounding code diverged. Re-run tests—context around the patch may differ from the original branch.

Example

Agent branch has three commits; only the middle one fixes the bug. Cherry-pick that SHA onto a clean hotfix branch and abandon the rest.

Agentic coding use

Cherry-pick is a surgical tool for agent outputs. It rewards small, coherent commits. Huge mixed commits are hard to cherry-pick cleanly—another reason to demand small agent commits.

Watch out

Cherry-picking the same fix onto multiple long-lived branches can duplicate patches and complicate later merges. Track what you already applied.

Sources