Interview Prep/Git & GitHub/Undoing Mistakes

You made four messy "wip" commits locally. You want a single clean commit before pushing.

IntermediateScenarioUndoing Mistakes
Answer

Situation read → Local, unpushed history can be collapsed.

What I'd do →

  1. git reset --soft HEAD~4 moves the branch back but leaves all changes staged.
  2. git commit -m "Add retry logic to payment client".
  3. Alternative: git rebase -i HEAD~4 and mark later commits squash or fixup.

Why → Soft reset only moves the branch pointer; index and working tree stay as they are.

Interview tip → git commit --fixup <sha> plus git rebase -i --autosquash is the polished workflow.

All Git & GitHub questions Roadmap: Git & GitHub

More on Undoing Mistakes