How to Use git cherry-pick to Apply a Specific Commit

git cherry-pick applies the changes from one specific commit onto your current branch, without merging the entire branch it came from.

Published September 20, 2026

git cherry-pick <hash> copies a single commit from another branch onto your current branch as a new commit. Use it to bring over one bug fix without merging everything.

The concept

Cherry-pick re-applies the diff of one commit on top of your current HEAD, creating a new commit with a different hash but the same message and changes.

Because it copies instead of merges, Git does not remember the relationship, so merging the branches later may produce duplicate or conflicting changes.

One commit moves across

feature: A─B─C─D─E
main: A─B─X
git switch main && git cherry-pick D
main: A─B─X─D' (D' = copy of D)

Practical examples

Pick one commit

git switch main
git cherry-pick a1b2c3d

Pick a range

git cherry-pick A..B   # commits after A up to B

Resolve a conflict

# fix files
git add .
git cherry-pick --continue
# or
git cherry-pick --abort

Record where it came from

git cherry-pick -x a1b2c3d

Common mistakes

  • Cherry-picking instead of merging, then creating duplicate commits.
  • Picking commits that depend on earlier unpicked ones.
  • Not using -x on release branches, losing traceability.

Key takeaways

  • cherry-pick copies one commit as a new commit.
  • Handy for hotfixes and backports.
  • Resolve conflicts then --continue.

FAQ

Does it remove the commit from the source branch?

No, the original stays where it was.

How do I cherry-pick without committing?

Use git cherry-pick -n <hash> to stage the changes only.

More Git articles