Ad space (banner)
🌿Git Lessons
Lesson 25 / 59

Undoing a Commit with git revert

This lesson covers undoing a commit with git revert. It's for anyone searching "git revert usage."

git revert creates a brand-new commit that undoes a specific past commit's changes, without rewriting history. Use it when you need to safely undo something that's already been shared with others.

In Try It, run git revert with the commit hash you found via git log, and a new commit that undoes that commit's changes is automatically created.

A common early mistake is confusing it with git reset — reset rewrites history itself, while revert leaves history intact and instead records an "undo" as a new addition, which is why it's safe to use on history that's already been shared. In real teams, if a problematic commit has already been pushed to the remote, revert — which doesn't rewrite history — is the standard, recommended way to undo it.

Git
Try it (type this into the pseudo terminal)
git log

🧑‍💻 You can type this command into the Git pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)