Git Cherry-Pick
Copy individual commits across branches without full merges.
- git cherry-pick
- backport
- cherry pick range
- copy commit
- hotfix
Git Cherry-Pick
Copy individual commits across branches without full merges.
Commands
| Command | What it does |
|---|---|
git cherry-pick <commit> | Apply one commit onto the current branch |
git cherry-pick -n <commit> | Apply to working tree without committing |
git cherry-pick --abort | Cancel a conflicted cherry-pick |
git cherry-pick --continue | Resume after resolving |
git cherry-pick main~3..main | Pick a commit range |
Example
git switch release/1.2
git cherry-pick a1b2c3d # backport hotfix
git push
FAQ
When is cherry-pick better than merge?
For backporting single hotfixes to release branches where merging whole feature history would be wrong.
Does cherry-pick preserve the commit hash?
No — it creates a new commit with a new hash; note the origin in the message for traceability.
Preguntas frecuentes
When is cherry-pick better than merge?
For backporting single hotfixes to release branches where merging whole feature history would be wrong.
Does cherry-pick preserve the commit hash?
No — it creates a new commit with a new hash; note the origin in the message for traceability.
Git
Git Config Essentials
Set identity, defaults, and aliases for Git on a new machine.
Git Clone and Init
Start a repo from scratch or copy a remote repository locally.
Git Add and Commit
Stage changes and record them as commits with clear messages.
Git Branch Basics
Create, list, rename, and delete branches for parallel work.