Git Commands
An overview of the most important Git commands
Git Commands featured image

git revert

The "revert" command helps you undo an existing commit.

It's important to understand that it does not delete any data in this process: instead, Git will create new changes with the opposite effect - and thereby undo the specified old commit.

Important Options

<commit-hash>

Specifies the commit you want to undo. Note that you can also provide multiple commit hashes if you want to revert multiple commits in one go.

--no-commit

Does not directly commit the created changes. By default, the reverting changes would be directly committed by Git. With the "--no-commit" option, the changes will only be created, but not committed. You could then edit them further and commit them manually.

--no-edit

Use the default commit message that Git suggests. By default, you would be prompted to enter a commit message for the new commit that is about to be created in the process. Using "--no-edit", however, you signal that you do not want to provide your own message, but simply go with the standard message that Git proposes.

The Git Cheat Sheet

No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!

Usage Examples

Simply provide the hash of the commit you want to undo:

git revert a72ef02

Git will then create changes that have the exact opposite effect of the changes contained in this original commit - effectively undoing them. Use the "--no-commit" option if you want to inspect (and possibly further modify) these changes and commit them manually:

git revert a72ef02 --no-commit


Tip

Right-Click to Revert

With the Tower Git client, reverting commits (and using many other "undo" tools in Git) becomes a breeze:

Try it free for 30 days and see why 100,000 developers all over the world use Tower to be more productive with Git!


Learn More

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.