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 →
- For plain commits:
git cherry-pick -x A^..F. - For a merge commit:
git cherry-pick -m 1 <merge-sha>applies the diff against the first parent. - Often simpler: cherry-pick the single squash commit if the PR was squashed.
- 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.
More on Rebase, Cherry-pick and History Rewriting
Your PR branch has ten commits like "wip", "fix typo", "oops". How do you clean it up before review?BeginnerYou want the database migration commit to come before the code that uses it.BeginnerA critical fix on `main` must go to the `release/4.1` branch only.BeginnerBranch B was built on top of branch A. A was squash-merged into `main`, and now B shows A's commits again.IntermediateDuring review you get ten small change requests on old commits. How do you apply them cleanly?IntermediateDuring a rebase, "ours" and "theirs" seem backwards. Why?Intermediate