how to undo a commit in git after push code example

Example 1: undo commit git before push

git reset HEAD~

Example 2: revert last push to server

git reset --hard HEAD@{1}
git push -f

Example 3: git undo pushed commit

git reset <previous label or sha1>
git commit -am "commit message"
git push -f <remote-name> <branch-name>  //  git push -f origin master

Example 4: github undo last pushed commit

git reset <previous label or sha1>
git commit -am "blabla"
git push -f <remote-name> <branch-name>

Example 5: git how to undo a pushed commit

git revert <commit_hash>