Preferred to use over reset if commits have been pushed to remote as does not remove commit history but rather creates a new commit.
[undo the changes of the last commit]
git revert HEAD
[undo the changes of the specified commit. Only changes made in the single commit will be undone not those of subsequent commits]
git revert <commit-id>