Appearance
Cherry-pick quick reference
Basic
| Command | Purpose |
|---|---|
git cherry-pick <sha> | Apply one commit to HEAD |
git cherry-pick -x <sha> | Add (cherry picked from ...) trailer |
git cherry-pick -s -x <sha> | Sign off + trailer |
git cherry-pick -n <sha> | Apply diff without committing (staging) |
git cherry-pick -m 1 <merge-sha> | Pick changes from a merge (first parent) |
Multiple commits
bash
git cherry-pick -x A^..D # A through D
git cherry-pick -x sha1 sha2 # explicit list, oldest firstConflict recovery
bash
# Resolve files, then:
git add <file>
git cherry-pick --continue # proceed
git cherry-pick --skip # drop this commit, continue sequence
git cherry-pick --abort # cancel entirelyDevOps patterns
bash
# Backport to multiple release branches
for b in release/1.x release/2.x; do
git checkout "$b" && git cherry-pick -x "$FIX_SHA"
done
# Promote through environments
git checkout prod && git cherry-pick -x staging~2..staging
# Verify fidelity after backport
git range-diff main~1..main HEAD~1..HEADCommon flags
| Flag | Use |
|---|---|
-x | Trailer for traceability — use every backport |
-n | Stage only, no commit |
-e | Force message editor |
-m <n> | Mainline parent for merge commits |
--allow-empty | Allow zero-diff commits |
--strategy=recursive -X theirs | Auto-resolve conflicts toward the picked diff |