Last Updated: 2021-05-15
A revert is a reverse patch. It totally undoes a change set - but without rewriting history. Therefore it shines when you've already pushed to a remote.
To revert the last three commits, you can feed it a range:
git revert HEAD~3..HEAD
You can do the same range trick with commit hashes
git revert ads89ads..zsdf4321
If you are considering undoing multiple commits, you may want the
option so as to reduce noise from having too many revert commits:
git revert --no-commit hash1 hash2 # ... and after this just commit every single revert as one commit git commit -m "Message"