Interview Q&A / Git & GitHub

IntermediateQuick answer1 min readUpdated 3 Oct 2026

How do you cherry-pick a range of commits, and what if there is a conflict?

SHORT ANSWER

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

bash
git cherry-pick 1a2b3c4^..5d6e7f8
# CONFLICT in billing.js
git add billing.js
git cherry-pick --continue
git cherry-pick --abort

What 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.

#git#cherry-pick#conflicts

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.