Skip to content
BENIBIX Learn

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.

Development🔀 Version Control

Git Revert

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

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.
Why it matters
It is the safe way to undo on a shared branch. Nobody's copy of the history breaks.
Full entry
Development🔀 Version Control

Git Reset

Moving a branch back to an earlier commit. Later commits drop out of it.

Git reset moves your branch back to an earlier commit. The commits after it drop out of the branch. The soft mode keeps their changes staged. The default, mixed mode keeps the changes in your files but unstaged. The hard mode throws the changes away, and that cannot be undone easily.

Example
Emma made two messy commits she has not pushed. She runs git reset --soft HEAD~2 and commits again as one.
Why it matters
It cleans up local work before you share it.
Full entry

In one line

Git Revert
A new commit that undoes an old one. The old one stays in the history.
Git Reset
Moving a branch back to an earlier commit. Later commits drop out of it.