Apply specific commits from one branch to another.
medium risk
git cherry-pick applies the changes introduced by specific commits (by hash) to the current branch, creating new commits with the same changes. Useful for backporting fixes to release branches without merging all changes.
| Flag | Meaning |
|---|---|
-n --no-commit | Apply changes without creating a commit |
-x | Append original commit hash to message |
--abort | Cancel cherry-pick in progress |
--continue | Continue after resolving conflicts |
git cherry-pick abc1234Apply commit abc1234 to current branch · explain & risk-check →git cherry-pick abc1234..def5678Apply a range of commits · explain & risk-check →git cherry-pick -n abc1234Stage changes without committing · explain & risk-check →Use `git cherry-pick -x` to include the original commit hash in the message — creates a paper trail linking the backport to the original fix, invaluable for tracking.
Reference text is hand-written and may be incomplete — check man git for your version. Test destructive commands on a non-production system first.