Cherry-picking is a Git operation that applies the changes introduced by one specific commit onto your current branch, creating a new commit with the same diff but a different hash. It lets you take just one change from another branch rather than merging everything.
Why it matters
Cherry-picking is common for backporting a bug fix from the main branch to a maintained release branch, or for rescuing a single useful commit from an abandoned branch. Because it copies the change, the same fix then exists as two unrelated commits, which can confuse history and cause conflicts when the branches are later merged. It works best for small, self-contained commits that do not depend on earlier ones.
Example
git switch release-1.4
git cherry-pick 9fceb02
# or a range
git cherry-pick A..B
The fix from commit 9fceb02 is now on release-1.4 as a new commit. Adding -x appends the original hash to the message.
Common mistakes
- Cherry-picking a commit that relies on earlier changes not present on the target branch.
- Overusing it as a substitute for proper branching, creating duplicated commits.
- Forgetting to resolve conflicts and run
git cherry-pick --continue.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.