What is git cherry-pick and when to use it?
Apply specific commits to your current branch.
When to Use
- Hotfix to multiple branches ```bash
git checkout main git log # Find commit: abc123 git checkout release/v1.0 git cherry-pick abc123 ```
- Pull single feature ```bash
git cherry-pick feature-commit-hash ```
Basic Usage
```bash
git cherry-pick
git cherry-pick commit1 commit2 commit3
git cherry-pick start-commit^..end-commit ```
Handle Conflicts
```bash $ git cherry-pick abc123
$ git add . $ git cherry-pick --continue
$ git cherry-pick --abort ```
Real Example
```bash
git checkout main git log --oneline
git checkout production git cherry-pick abc123 git push ```
Best Practices
✅ DO:
- Cherry-pick bug fixes to release branches
- Port urgent fixes across versions
- Extract specific features
❌ DON'T:
- Cherry-pick many commits (use merge/rebase)
- Cherry-pick from public branches frequently
- Use as primary integration method
Interview Q&A
Q: Cherry-pick vs merge? A: Cherry-pick: select specific commits. Merge: integrate entire branch history.
Q: Does cherry-pick create new commit? A: Yes, creates new commit with same changes but different hash.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.