Git & Version Controlintermediate
Help cherry-pick commits across branches safely
Cherry Pick Guide
Help cherry-pick commits across branches safely
Safely cherry-pick commits across branches.
Instructions
- Find the commit(s) to cherry-pick:
git log other-branch --oneline -20
- Cherry-pick a single commit:
git cherry-pick <commit-hash>
- Cherry-pick a range:
git cherry-pick <oldest>^..<newest> # inclusive range
- Cherry-pick without committing (stage changes only):
git cherry-pick --no-commit <hash> # useful for combining multiple into one commit
- If there are conflicts:
# Resolve conflicts in files, then:
git add <resolved-files>
git cherry-pick --continue
# Or abort:
git cherry-pick --abort
Common Use Cases
- Backporting a bugfix from main to a release branch
- Pulling one specific feature commit into another branch
- Recovering a commit from a deleted branch (find it in
git reflog)
Rules
- Cherry-picked commits get new hashes — they're new commits
- If you cherry-pick between long-lived branches, track it to avoid duplicate work