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 --continueOptions
| Flag | What it does |
|---|---|
| -x | Append a "cherry picked from commit" line |
| -n / --no-commit | Apply changes without committing |
| -m <parent> | Pick a merge commit, choosing the mainline |
| --continue / --abort / --skip | Manage 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
git revert: Usage, Options & Common CI Errorsgit revert undoes a commit by creating a new inverse commit, keeping history intact. Reference for -m, --no-c…
git rebase: Usage, Options & Common CI Errorsgit rebase replays commits onto a new base to keep history linear. Reference for -i, --onto, --continue, --ab…
git merge: Usage, Options & Common CI Errorsgit merge joins two branch histories into one. Reference for --no-ff, --squash, --abort, and how to detect an…
git log: Usage, Options & Common CI Errorsgit log shows commit history with flexible formatting. Reference for --oneline, --graph, --pretty, ranges, an…