git reset --hard <the-sha-you-want-to-return-to>
Or This will undo the last commit.
git reset --hard HEAD~1
Or This will undo the last two commits.
git reset --hard HEAD~2
Push the updated history to the remote. You need to pass the -f because you're replacing upstream history in the remote.
git push -f <remote> <branch>