[Git] Undo a commit that has already been pushed to the remote repository

If we pushed our changes already to the remote repository we have to pay attention to not change the git history (using commands like rebase, reset, amend etc). Other collaborators of the same repository might already have pulled your changes, thus resulting into horrible, strange merge conflicts if we change the git history. There are some “safer commands” for undoing in such cases.

If you push something we shouldn't push to git, we can revert it:

First, using git log to get the commit id you want to revert, then using:

git revert <commit_id>

Then push to git

原文地址:https://www.cnblogs.com/Answer1215/p/10603429.html