history

git cherry-pick

Applies the changes from one or more specific commits onto the current branch as new commits. Useful for porting bug fixes across branches.

git cherry-pick [<options>] <commit>...

Common flags

Flag Purpose
-x Append a 'cherry picked from' line to the message
-n / --no-commit Apply changes without auto-committing
--continue Resume after resolving conflicts
--abort Cancel the cherry-pick and restore prior state
-e / --edit Edit the commit message before recording
-m <parent> Cherry-pick a merge commit relative to given parent

Examples

git cherry-pick abc123

Apply commit abc123 onto the current branch

git cherry-pick abc123..def456

Pick a range of commits (exclusive of abc123)

git cherry-pick -x hotfix~1

Backport a fix with an attribution line

Gotcha

Cherry-picking creates a new commit with a different SHA; picking the same fix onto multiple branches can duplicate history if later merged.

Related commands

← All Git commands · Git cheat sheet · Git rebase vs merge