Link: Git

Revert the last commit

https://stackoverflow.com/questions/6655052/is-there-a-way-to-rollback-my-last-push-to-git

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: https://stackoverflow.com/questions/6459080/how-can-i-undo-a-git-commit-locally-and-on-a-remote-after-git-push