Cherry-Pick

Updated

October 30, 2026

Cherry-Pick: Moving Commits Surgically

After this page you can copy one commit onto another branch without merging the whole feature.

Copy the patch, new hash

cd ~/desk/desk-api
git switch main
git cherry-pick <hash>

Git takes the diff of that commit against its parent, applies it onto HEAD, and writes a new commit. The new object has a new hash. Author is preserved; you are the committer.

 feat    A ← B ← C ← D ← E          pick D only
 main    A ← B ← C

 after   A ← B ← C ← D'             main   (D' ≈ patch of D, new hash)
 feat    A ← B ← C ← D ← E          unchanged
git log -1 --format=fuller

Several commits

git cherry-pick abc123 def456
git cherry-pick main~3..feat/ping-json

A range A..B is commits reachable from B excluding A. Oldest is applied first.

Conflicts

Same markers as merge. Then:

git add src/ping.py
git cherry-pick --continue
git cherry-pick --abort
git cherry-pick --skip

Same loop as rebase, one commit at a time.

Empty pick

If main already contains the change, Git says the pick is empty. --skip or --allow-empty.

What cherry-pick is for

  • A hotfix that lives on a release branch and also needs to be on main
  • A commit that landed on the wrong branch
  • Backporting a fix to an older release/* line

What it is a poor fit for: dragging a whole feature. Merge or rebase the branch instead so you get the whole chain and a honest graph.

Next page: hotfixes and backports as a desk scenario.