Cheat Sheets · Git Cheat Sheet · Git Cherry Pick — Apply a Specific Commit Elsewhere
Git Cherry Pick — Apply a Specific Commit Elsewhere
git cherry-pick <sha>Apply a single commit onto current branch
git cherry-pick <sha-1> <sha-2>Apply multiple specific commits in sequence
git cherry-pick <old>..<new>Apply a range of commits (exclusive of old)
git cherry-pick -n <sha>Apply diff into working tree without committing (-n / --no-commit)
Cherry pick commands
| Command | Effect |
|---|---|
git cherry-pick <sha> | Apply a single commit onto current branch |
git cherry-pick <sha-1> <sha-2> | Apply multiple specific commits in sequence |
git cherry-pick <old>..<new> | Apply a range of commits (exclusive of old) |
git cherry-pick -n <sha> | Apply diff into working tree without committing (-n / --no-commit) |
Handling conflicts during cherry pick
| Command | Action |
|---|---|
git cherry-pick --continue | Resume cherry-pick after resolving conflicts and staging files |
git cherry-pick --abort | Cancel cherry-pick and restore branch to pre-pick state |
git cherry-pick --skip | Skip the current problematic commit in a multi-commit pick |
Cherry-picking copies the diff introduced by a specific commit from one branch and commits it directly onto your current branch with a new SHA.
Related Git recipes
FAQ
Does cherry-pick delete the commit from the original branch?
No. Cherry-pick duplicates the changes. The original commit stays completely untouched on its source branch.
Why does cherry-pick give a new commit SHA?
Because commit SHAs are hashes of their tree, message, timestamp, AND parent commit. Changing parents means a new SHA.
What if I cherry-pick an already merged commit?
Git detects an empty patch and prompts you to skip it with git cherry-pick --skip.
Stop memorizing — build it interactively
Try cherry-pick in the Git BuilderFull reference: Git Cheat Sheet