Throw away local commits in Git
If your excess commits are only visible to you, you can just do
git reset --hard origin/<branch_name>
to move back to where the origin is. This will reset the state of the repository to the previous commit, and it will discard all local changes.
Doing a git revert
makes new commits to remove old commits in a way that keeps everyone's history sane.
Simply delete your local master branch and recreate it like so:
git branch -D master
git checkout origin/master -b master
Delete the most recent commit, without destroying the work you've done:
git reset --soft HEAD~1
Delete the most recent commit and remove changes:
git reset --hard HEAD~1