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

During review you get ten small change requests on old commits. How do you apply them cleanly?

IntermediateScenarioRebase, Cherry-pick and History Rewriting
Answer

Situation read → You want fixes folded into the right commits, not a pile of "address review" commits.

What I'd do →

  1. For each fix: git add -p && git commit --fixup <target-sha>.
  2. When done: git rebase -i --autosquash origin/main.
  3. Enable permanently: git config --global rebase.autoSquash true.
  4. Push with --force-with-lease; mention it in the PR so reviewers re-check.

Why → Fixup commits are auto-ordered and squashed, so history reads as if the code was right the first time.

Interview tip → Some teams prefer review fixup commits until approval to ease re-review. Know both.

All Git & GitHub questions Roadmap: Git & GitHub

More on Rebase, Cherry-pick and History Rewriting