[Git] Undo a Commit that has Already Been Pushed

Once a commit is pushed, you do NOT want to use git reset to undo it - because reset will rewrite the history tree, and anyone who has already pulled that branch will have a bad tree.

Instead, we'll use git revert to make a "revert commit" (like a merge commit), which will "undo" a specific commit. So the syntax is:

git revert [HASH-TO-UNDO]

git log --oneline

     f23481b (HEAD -> master, origin/master, origin/HEAD) take 3

 

git revert f23481b

 

Guess you like

Origin www.cnblogs.com/Answer1215/p/12171563.html