Algocraft / Git Commands / git cherry-pick

🍒

git cherry-pick

Copy one specific commit onto your current branch — without merging or rebasing the whole branch it came from

Single Commit New Hash
Commit Graph Step 0 / 0
Working Directory → Staging → Repository
Terminal Transcript

Key Concepts

🎯 When to Use
  • Backporting a bugfix to a release branch
  • Pulling one useful commit out of an abandoned branch
⚖️ vs Merge / Rebase
  • Merge/rebase move whole ranges of commits
  • Cherry-pick moves exactly one, by choice
  • Overusing it can duplicate history — merge/rebase later once the whole branch is ready
🎓 Pro Tips
  • cherry-pick A..B picks a whole range of commits at once
  • Conflicts can happen just like a merge — resolve, then --continue