38 / 57 · 17 Git & Version Control · Bisect and Cherry-Pick← prev⊞ allnext →☰ Read as one page
5.8Cherry-Pick Best Practices
- Cherry-pick creates a new commit: The original and cherry-picked commits have different hashes. Git does not know they are related.
- Conflicts are common: If the cherry-picked commit depends on prior changes that do not exist on the target branch, you will get conflicts.
- Prefer merge or rebase when possible: Cherry-pick is for targeted, exceptional cases. If you find yourself cherry-picking frequently, your branching strategy may need adjustment.
- Document cherry-picks: Add a note in the commit message: "Cherry-picked from abc123f on develop."
# Cherry-pick with a note
git cherry-pick abc123f --edit
# In the editor, add: "(cherry-picked from abc123f on develop)"