Revert
Also called: back out.
Undoing a commit by adding a new commit that is its exact opposite, so the bad change goes away and the history keeps both commits. Everyone who already pulled the branch can keep working, which is why shared branches are fixed with git revert, not by deleting the commit and force-pushing. A revert only changes code: data the bad version already wrote stays wrong until you fix it.
Revert B adds a new commit that undoes B and keeps the history. Undo by rewriting history drops B and force-pushes main, while Ana has work built on the old history.
Chips are commits, newest on the right. B broke checkout · Meter tick: the 1% error limit
Commits on main: 3 · Errors: 9% · Rejected pushes: 0
Commit B on main broke checkout, and 9% of requests fail. Ana has a commit D built on top of C.
Say it in a prompt
Commit b4d1e02 ("Add discounts") on main broke checkout. If the pipeline can redeploy the previous build, do that first: it is faster than any new commit. Then run git revert b4d1e02, push the revert commit to main (through a pull request if your team requires one) and let CI deploy it; check the checkout error rate is back under 1%. Don't reset or force-push main. If b4d1e02 is a merge commit, use git revert -m 1 b4d1e02. To bring the change back once it is fixed, revert the revert. Fix the orders the bad version saved with wrong totals: the revert doesn't touch data. Vague vs precise prompt
Vague prompt
undo the commit that broke checkout Typical resultRewrites main without that commit and force-pushes. Production recovers, but every teammate who pulled main now has history that doesn't match, their pushes are rejected, and a plain git pull merges the bad commit back in.
Precise prompt
Run git revert b4d1e02 on main, push the revert commit to main (through a pull request if your team requires one) and let CI deploy it; don't force-push main. Check the checkout error rate is back under 1%, then fix the orders the bad version saved. Typical resultmain gets one new commit that undoes b4d1e02, history keeps both, teammates just pull, and errors drop after the deploy. The orders saved with wrong totals are fixed on their own, since a revert only changes code.
Seen on
- Git docs, git revert: git revert records new commits that reverse the effect of earlier ones. Reverting a merge needs -m to name the mainline parent, and it declares you never want that merge's changes, so a later merge of the same branch won't bring them back by itself.
- GitHub Docs, Reverting a pull request: Reverting a merged pull request creates a new pull request that reverts the original merge commit; merging it finishes the revert.
- Pro Git book, Rebasing: Warns not to rebase commits that exist outside your repository and that people may have based work on, and shows the mess a force-push leaves for teammates who did.
- Google SRE Workbook, Incident Response: Rolling back a recent release is a generic mitigation: when an outage lines up with a release, going back to a known good version speeds recovery before the cause is fully understood.
You might describe it as
- undo that commit without rewriting history
- add a commit that takes the bad change back out
- back out the change on the shared branch so nobody's copy breaks
Not to be confused with
- Hotfix
A revert undoes one commit by adding its exact opposite, on any branch, with no new code to write; a hotfix is the urgent path that ships a fix to the release that is live, and its one commit is often itself a revert made on the release branch.