git revert - How to "git undo"?

5.4.1. git revert - How to "git undo"?#

git revert  creates a new commit that undoes changes from a specific commit or range of commits.

Example: git revert:

Shown is output of git log --format=oneline:

349... (HEAD -> main, origin/main, origin/HEAD) Initial commit

git revert HEAD

cae... (HEAD -> main) Revert "Initial commit"
349... (origin/main, origin/HEAD) Initial commit

git revert HEAD

435... (HEAD -> main) Reapply "Initial commit"
cae... Revert "Initial commit"
349... (origin/main, origin/HEAD) Initial commit