How do you cherry-pick a range of commits, and what if there is a conflict?
Use git cherry-pick A^..B to copy commits from A through B. On conflict, fix the files, git add them and run git cherry-pick --continue, or use --abort to cancel.
Explain it simply
Taking three consecutive commits is the same as taking one, repeated. The range A^..B means 'from A inclusive up to B inclusive'; A..B would skip A itself.
If one commit conflicts, Git stops and marks the files like a merge. Edit, git add, then git cherry-pick --continue. --skip drops the current one and --abort restores the original state. To collect changes without committing yet, add -n.
Example
git cherry-pick 1a2b3c4^..5d6e7f8
# CONFLICT in billing.js
git add billing.js
git cherry-pick --continue
git cherry-pick --abortWhat to say in the interview
"For a range I use cherry-pick A^..B so A is included. On a conflict I resolve, add, and continue, or abort to go back. The -n option stages the changes without committing."
Common mistakes
- Writing A..B and wondering why the first commit is missing.