A release introduced a regression from five consecutive commits. How do you revert them as one change?
IntermediateScenarioUndoing Mistakes
Answer
Situation read → You want one clean revert rather than five.
What I'd do →
- Find the range:
git log --oneline -8. git revert --no-commit OLDEST^..NEWESTapplies all inverses to the index, newest first.- Fix conflicts if later commits overlap, then
git commit -m "Revert checkout rewrite (INC-4821)". - Push and open a PR for review.
Why → --no-commit lets you bundle the reverts and describe them with the incident reference.
Interview tip → Alternative: revert the single squash or merge commit that brought the work in.
More on Undoing Mistakes
You committed on `main` when you meant to be on a feature branch. Nothing is pushed. Fix it.BeginnerYou made a typo in your last commit message and have not pushed.BeginnerA bad commit is already on shared `main`. Others have pulled it. How do you undo it?IntermediateYou ran `git reset --hard` and lost uncommitted-then-committed work. Can you get it back?IntermediateYou need to revert a merge commit on `main`. `git revert` says "commit is a merge but no -m option was given".IntermediateYou deleted a local branch with unmerged work by mistake.Beginner