Cherry-pick a commit onto this branch
Medium risk
What do risk levels mean?
- Read-only
- Inspects state without changing anything.
- Low risk
- Reversible with a routine follow-up command.
- Medium risk
- Changes state; undo path documented.
- Destructive
- Deletes or overwrites; confirmation required.
Copies the changes of a single commit from another branch onto the current branch as a new commit, without merging the whole branch.
gitcherry-pickcommit
Parameters
Hash of the commit to copy onto the current branch.
Commands
Confirm which commit and files will be copied
git show --stat <commit>Apply the commit's changes to the current branch as a new commit
git cherry-pick <commit>Verification
git log --oneline -1A new commit with the cherry-picked change sits at the branch tip.
Undo
Remove the cherry-picked commit and restore the previous branch tip
git reset --hard 'HEAD@{1}'Pitfalls
- Conflicts pause the cherry-pick; resolve them and run git cherry-pick --continue, or abort with git cherry-pick --abort.
- The copied commit gets a new hash; merging the source branch later can produce duplicate changes.