Git is usually about managing streams of history. You merge rivers of code together. But sometimes, you don’t want the whole river. You just want one specific fish.
That’s git cherry-pick.
What Is Git Cherry-Pick?
Git cherry-pick is a Git command that takes the changes from a single specified commit and applies them to the current branch as a new commit, without merging the rest of that commit’s branch history.
Git cherry-pick is highly useful in specific scenarios:
- Hotfixes: You fixed a bug in
dev, and you need that same fix inprodright now, but you can’t mergedevyet because it has unfinished features. - Mistakes: You committed to the wrong branch.
How to Use Git Cherry-Pick: Step-by-Step Workflow
Let’s say you are on main and you want commit abc1234 that exists on feature-branch.
- Find the hash:
git log feature-branch # verify that abc1234 is the one you want - Execute the pick:
git checkout main git cherry-pick abc1234
Git takes the diff from that commit and tries to apply it to main. If successful, it automatically creates a new commit with a new SHA — the content matches the original commit, but the commit hash does not.
Resolving Git Cherry-Pick Conflicts
Just like a merge, cherry-picking can result in conflicts if the code has diverged too much. When this happens, Git pauses and prints an error similar to:
error: could not apply abc1234... <commit message>
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
Error: could not apply <hash>... <message>
Cause: the cherry-picked commit’s diff conflicts with changes already on the current branch.
Fix:
- Open the conflicted files and resolve the
<<<<<<<,=======, and>>>>>>>conflict markers. git add <file>git cherry-pick --continue
If you want to cancel the operation entirely instead, run git cherry-pick --abort to return the branch to its pre-pick state.
Error: The previous cherry-pick is now empty
Cause: the changes from the picked commit are already present on the current branch (often after manual conflict resolution), so Git has nothing left to commit.
Fix: run git cherry-pick --skip to move past the empty commit, or git commit --allow-empty if you specifically want to preserve it as a marker in history.
When Not to Use Git Cherry-Pick: Merge and Rebase Alternatives
Don’t use cherry-picking as a substitute for proper merging. If you find yourself cherry-picking 10 commits in a row, you are probably doing it wrong—you should likely be merging or rebasing instead.
Cherry-picking creates duplicate commits (different SHA hashes, same content diff). If you later merge the branches, Git is usually smart enough to figure it out, but it creates a messy history. Use cherry-pick sparingly.
Git Cherry-Pick: Definitive Use Case Summary
Git cherry-pick represents a precision-application technique that copies a single commit’s diff onto another branch without importing that branch’s full history. You won’t use it every day, but when you need to extract a critical fix without bringing in unwanted baggage, it is the tool for the job.
See the official Git documentation on cherry-pick for the complete flag reference (--no-commit, -x, -m).
Git Cherry-Pick FAQ
What does git cherry-pick do?
Git cherry-pick takes the changes introduced by a single specified commit and applies them to the current branch as a new commit with a new SHA, without merging the rest of that commit’s branch history.
How is git cherry-pick different from git merge?
git merge brings in the full history of another branch, while git cherry-pick applies only one specific commit’s diff, leaving the rest of the source branch’s history untouched.
Can I cherry-pick multiple commits at once?
Yes. Pass a range or a list of hashes, for example git cherry-pick abc1234 def5678, or a range like git cherry-pick abc1234^..def5678 to apply a contiguous sequence of commits.
What happens if git cherry-pick hits a conflict?
Git pauses the operation and reports error: could not apply <hash>... <message>. Resolve the conflict markers in the affected files, stage them with git add, then run git cherry-pick --continue (or git cherry-pick --abort to cancel).
How do I cancel a cherry-pick in progress?
Run git cherry-pick --abort to stop the operation and return the branch to the state it was in before the cherry-pick started.
Did you like this post? Please let me know if you have any comments or suggestions.
Git posts that might be interesting for youEnjoyed this? Get more like it.
Weekly notes on AI tools, Python, and what I'm actually building — plus a free copy of Fantastic AI: The 2026 Toolkit.