Your PR branch has ten commits like "wip", "fix typo", "oops". How do you clean it up before review?
BeginnerScenarioRebase, Cherry-pick and History Rewriting
Answer
Situation read → Private, unreviewed history can be rewritten. Reviewers want a readable story.
What I'd do →
git rebase -i origin/main.- Keep the first meaningful commit as
pick; change the noise commits tosquash(merge messages) orfixup(discard messages). - Rewrite the final messages in the editor.
git push --force-with-lease.
Why → One logical commit per change makes review, bisect and revert simple.
Interview tip → Say you only rewrite commits nobody else has based work on.
More on Rebase, Cherry-pick and History Rewriting
You 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?IntermediateDuring a rebase, "ours" and "theirs" seem backwards. Why?Intermediate