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 and flow from this site, held on your device and searchable with no connection. Free to install, no ads.
Get it free on the App Store