All jobs / DevOps / SRE / cloud / Git
DevOps / SRE / cloud interview question · 1–3 years
A commit on main broke the build; three teammates have already pulled it.
How do you undo it?
The strongest answer
`git revert` the commit — a new commit that inverts it — push, and fix forward afterwards; history stays intact for everyone who already pulled
Why it works
Right — revert is the safe undo on shared history: it is additive, instant and reviewable.
What a good answer covers
- Revert, do not rewrite.
- Restore green first.
- Then fix forward.
- Never force-push main.
Answers that fall short
- Close, but not the strongest: Fix the bug in a new commit as fast as I can; reverting is extra churn
Fixing forward is fine when it is minutes away; a revert restores green immediately and buys the time to fix properly. - Weak: Delete the branch and recreate main from the last good commit
Recreating main rewrites shared history with extra steps and breaks every clone. - Red flag: `git reset --hard` to the previous commit and `push --force` so the bad commit never existed
Force-rewriting main after others pulled it corrupts their history and hides what happened — a red flag.
Who gets asked this
More Git questions
- What is a git tag for in a release pipeline?
- Production runs v2.3.0. main has two weeks of unreleased work. A critical bug must ship today. What is your…
- p95 latency doubled somewhere in the 60 commits between last week’s release and today’s. Nothing in the diffs…
- What do you standardise, and where do you allow a difference?
- When do you rebase, and when must you never?