Interview Prep/Git & GitHub/Rebase, Cherry-pick and History Rewriting

You must backport a feature made of 6 commits, including one merge commit.

IntermediateScenarioRebase, Cherry-pick and History Rewriting
Answer

Situation read → Cherry-pick of a merge commit needs a mainline choice, and ranges skip merges by default.

What I'd do →

  1. For plain commits: git cherry-pick -x A^..F.
  2. For a merge commit: git cherry-pick -m 1 <merge-sha> applies the diff against the first parent.
  3. Often simpler: cherry-pick the single squash commit if the PR was squashed.
  4. If it stalls: fix, git add, git cherry-pick --continue, or --abort.

Why → A merge has no single diff; -m chooses which parent to diff against.

Interview tip → Squash-merged PRs make backports one-liners.

All Git & GitHub questions Roadmap: Git & GitHub

More on Rebase, Cherry-pick and History Rewriting