# Git Revert

> A new commit that undoes an old one. The old one stays in the history.

**Field:** Software Development  
**Category:** Version Control  
**Also known as:** git revert, Revert a Commit, Revert Commit

## Think of it like

Think of it like a new diary line that says to forget what you wrote yesterday. The old page stays.

## Definition

Git revert undoes a commit by making a new commit that does the opposite. If the old commit added a line, the new one takes it out. The old commit stays in the history. Nothing is deleted or rewritten. That makes it safe on a branch other people already have.

## Example

A bad change broke the order page on main. Jack reverts that commit, pushes, and the site works again.

## Example code

```console
$ git revert 7b8c9d0
[main 5e6f7a8] Revert "Fix the price on the order page"
 1 file changed, 1 insertion(+), 2 deletions(-)
```

A new commit undoes the old one, and both stay in the history.

## Why it matters

It is the safe way to undo on a shared branch. Nobody's copy of the history breaks.

## Common mistake

Using git reset on a branch others have pulled. Revert is the undo that does not rewrite history.

## Three principles

- **Adds, never deletes.** The undo is a new commit.
- **Safe to share.** History is not rewritten.
- **One commit at a time.** Name the commit to undo.

## Related terms

- [Git Reset](https://learn.benibix.com/term/development/git-reset)
- [Commit](https://learn.benibix.com/term/development/commit)
- [Commit Hash](https://learn.benibix.com/term/development/commit-hash)
- [Rollback](https://learn.benibix.com/term/development/rollback)
- [Git Commit Amend](https://learn.benibix.com/term/development/git-commit-amend)

## Told apart from

- [Git Revert vs Git Reset](https://learn.benibix.com/compare/git-revert-vs-git-reset): Git revert adds a new commit that undoes an old one, so the history stays. Git reset moves the branch back, so later commits drop off it. Use revert on shared branches, and reset only on your own work.

## Taught in

- [Undo a Git Commit](https://learn.benibix.com/learn/development-version-control/undo-a-git-commit): Git and GitHub, 7/13

![Three rows, each starting from commits A, B and C in a line. Revert, lit up, adds a new commit D that undoes C, so history only grows and is safe to share. Reset moves the branch label back from C to B, so C drops out of the branch. Amend swaps C for a new C with a fixed message or file. A note says reset and amend rewrite history, so use them only on commits you have not pushed.](https://learn.benibix.com/diagrams/dev3-undo-changes.svg)

---

Source: https://learn.benibix.com/term/development/git-revert
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
