git cherry-pick
Copying a single commit to another branch.
Cherry-pick takes the diff introduced by any commit and re-applies it on top of your current branch — creating a new commit with the same changes but a different hash. It's a surgical tool: take exactly this one thing, leave everything else.
Pick Your Commits
Click any commit on the feature branch to select it, then cherry-pick it onto main. You can pick multiple. Watch the hash change on arrival.
How It Works
Cherry-pick computes the diff between the picked commit and its parent — exactly what that commit changed. It then applies that diff on top of your current HEAD.
Because the parent commit is different, the resulting commit object has a different SHA-1. The changes are identical, but it is a genuinely new commit in the graph.
Cherry-pick can conflict just like a merge. If the code it's trying to patch no longer exists on the target branch, Git pauses for you to resolve the conflict, then git cherry-pick --continue.
When to Use It
- 🍒Hotfix backports. You fixed a critical bug on
main. Cherry-pick that fix onto thev2.0-stablerelease branch without merging all of main's newer commits. - 🍒Rescuing commits from a dead branch. Someone made a useful commit on a branch you're not merging. Cherry-pick the commit you want.
- 🍒Moving a commit placed on the wrong branch. Committed to
maininstead of your feature branch? Cherry-pick it there, then revert it from main.