git revert
CautionRevert a commit
git revert <commit>
Creates a new commit that undoes a given commit — safe, history-preserving.
Examples
git revert HEADUndo the last commit safely
Syntax
git revert <commit>
Before you run it
Adds an inverse commit.
Used when you see
Undo a bad commit/push
2
See the whole flow →After pushing, revert to undo safelyOn shared branches, revert beats rewriting.
Related commands
- git resetReset state
The same reference, with no signal at all
Every command on this site, held on your device. The app adds 632 more: 1,510 commands and 120 fix flows, searchable with no connection. Free to install, no ads (some content is a one-time purchase).
Get it free on the App Store