Link: Git

Revert the last commit

git reset --hard HEAD@{1}
git push -f
git reset --hard HEAD@{1}
# if it's for the private "fork" repo
git push -f origin HEAD:v4

Revert the full commit (no need to be the last one)

You can simply tell git to revert a commit, which does not even have to be the last one.

Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

# this will undo the history in local and remote repo
git revert commit_id
git reset --hard <the-sha-you-want-to-return-to>
git push -f
# Source: