You accidentally merged `main` into your feature branch three times and want a linear branch again.
IntermediateScenarioRebase, Cherry-pick and History Rewriting
Answer
Situation read → Merge commits are cluttering a branch that should be a clean series.
What I'd do →
git fetch origin.git rebase origin/main(without-r) drops the merges and replays only your own commits.- Resolve conflicts once per commit.
git push --force-with-lease.
Why → Default rebase ignores merge commits and picks the non-merge commits in the range.
Interview tip → If a merge itself had hand-resolved conflicts, check the final diff carefully, since that resolution may be lost.
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.BeginnerYou must backport a feature made of 6 commits, including one merge commit.IntermediateBranch 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?Intermediate