How to Undo Pushed Commit on GitHub

Apr 23, 2018

Question:

How to undo/remove the last pushed commit:

Answer:
git push -f origin HEAD^:master

 

Question:

How to undo/remove one specific pushed commit:

Answer:

  1. git log to find out the commit you want to revert
  2. git push origin +xxxxxx (commit number):master while xxxxxx is the commit number before the wrongly pushed commit. + was for force push

 

Question:

How to undo/remove a specific pushed commit:

Answer:
git reset ––hard xxxxxxx (commit number)
git push ––force

WARNING: This will rewrite the commit history as well

 

The question and answer are referred from Stackoverflow