Git Cherry-Pick Cheat Sheet

Git cherry-pick — selectively apply commits from one branch to another. Conflict resolution, ranges, and real-world use cases.

Last Updated: May 1, 2025

Cherry-Pick Commands

git cherry-pick commit
Apply a single commit to the current branch
git cherry-pick commit1 commit2
Apply multiple specific commits
git cherry-pick commit1..commit3
Apply a range (commit1 exclusive, commit3 inclusive)
git cherry-pick commit1^..commit3
Apply range INCLUDING commit1
git cherry-pick -x commit
Append '(cherry picked from commit SHA)' to message
git cherry-pick --no-commit commit
Stage changes without committing (review first)
git cherry-pick --signoff commit
Add Signed-off-by line to the commit message
git cherry-pick -m 1 merge-commit
Cherry-pick a merge commit (specify parent 1)

Handling Conflicts

git cherry-pick --continue
After resolving conflicts, continue cherry-pick
git cherry-pick --skip
Skip the current commit causing conflicts
git cherry-pick --abort
Abort the entire cherry-pick operation
git cherry-pick --quit
Stop but keep changes in working tree
git status
Check which files have conflicts during cherry-pick
git diff
Review changes before committing

Common Use Cases

ItemDescription
Backporting HotfixesCherry-pick a fix from main to release branch
Picking FeaturesSelectively move commits from experimental to stable branch
Undeleting CodeCherry-pick a commit that was reverted, after fixing the issue
Cross-Team SharingTeam A's utility commit needed by Team B's branch
Splitting PRsCherry-pick specific commits from a large PR into smaller ones
Restoring Stale WorkRevive commits from abandoned branches
Duplicate Branch FixesApply the same bugfix to multiple supported versions
Avoid Merge DependenciesGrab just the fix without merging an entire feature

Cherry-Pick vs Alternatives

OperationCherry-PickMergeRebase
ScopeIndividual commitsEntire branchEntire branch replays
HistoryCreates new commitsPreserves parent linksRewrites commit SHAs
Use CaseSelective portingIntegrate workLinearize history
TraceabilityUse -x flagMerge commit referenceOriginal context lost
Conflict LoadPer-commit conflictsOne merge conflictPer-commit conflicts
Pro Tip: Cherry-pick creates a new commit with a different SHA — use `-x` to add a reference to the original commit for traceability.