Skip to content
Latchkey

git cherry-pick: Usage, Options & Common CI Errors

git cherry-pick copies the changes from one or more commits onto your current branch as new commits.

Cherry-pick is how you port a fix to another branch. Conflicts pause it, like a rebase.

What it does

git cherry-pick takes the diff introduced by each named commit and applies it on top of the current HEAD, creating a new commit for each.

Common usage

Terminal
git cherry-pick <sha>
git cherry-pick -x <sha>          # add "cherry picked from" note
git cherry-pick A^..B             # a range of commits
git cherry-pick -n <sha>          # apply without committing
git cherry-pick --continue

Options

FlagWhat it does
-xAppend a "cherry picked from commit" line
-n / --no-commitApply changes without committing
-m <parent>Pick a merge commit, choosing the mainline
--continue / --abort / --skipManage an in-progress pick

Common errors in CI

error: could not apply <sha>… / "after resolving the conflicts, mark them with git add … then run git cherry-pick --continue" - the pick conflicts. Resolve and continue, --skip to drop the commit, or --abort to bail. Picking a merge needs -m.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →