Git cherry-pick — a copy, never a move
git cherry-pick <sha> copies one commit — same patch, new SHA, nothing moves. A..B excludes A; A^..B includes it. On conflict: resolve, git add, git cherry-pick --continue.
Git cherry-pick copies one commit — same patch, new SHA, nothing moves. The original stays exactly where it was; delete the source branch and the picked copy still stands. A range excludes its start: A^..B includes A, A..B skips it silently.
What does git cherry-pick actually do?
A fix lives on a feature branch; main needs it now. The pick repeats the patch and mints a new SHA.
git log feature/payment-fix --oneline -5 # find the SHA(s)git switch main # land in the right placegit cherry-pick 1a2b3c4 # copy it over# on conflict: resolve → git add → git cherry-pick --continuegit log -1 --stat # confirm what landed
Copy, not move: the picked commit has its own SHA and no dependency on the original.
| Command | Lands on target | History | Use when |
|---|---|---|---|
git cherry-pick <sha> | Named commits only | Copy, new SHAs | One specific fix must move now |
git merge <branch> | Everything in the branch | Merge commit or fast-forward | You want the whole branch, divergence visible |
git rebase <base> | Every commit of the branch, replayed | Linear, SHAs rewritten | You want a clean linear strip |
git revert <sha> | The inverse of a commit | Adds an undo commit | A landed commit must be undone on shared history |
- Find the SHA:
git log feature/payment-fix --oneline -5. - Switch to the receiving branch:
git switch main. The pick lands where HEAD points —git branch --show-currentfirst; detached HEAD leaves the commit orphaned. git cherry-pick 1a2b3c4, thengit log -1 --statto confirm what landed. Multiple:A..B,A^..B, or an explicit list.
why the pick stopped — four causes
git add <resolved-files> && git cherry-pick --continue git cherry-pick --abort git cherry-pick --skip git cherry-pick --allow-empty git cherry-pick -m 1 <merge-sha>
A conflict pauses mid-sequence — until --continue, git status still says You are currently cherry-picking. An empty pick ("The previous cherry-pick is now empty") means the change is already here, often from a squash merge; use --skip. A merge commit has two parents, so git refuses without -m; parent 1 is the branch you were on at merge time. First published 2026-09-12, record refreshed 2026-10-10.
- every command runs as printed on any recent git
- range: A..B excludes A · A^..B includes A · -n / --no-commit folds picks
- empty pick · -m parent numbering · conflict --continue — git's documented behaviour
- first published 2026-09-12 · record refreshed 2026-10-10