HOWTO undo a git push

Normally, undoing git remote commands is close to a nightmare, but a quick search returned the following for undoing git push command:

$ git hist
* abc123 <date> | Latest push
* abc100 <date> | 2nd last push

Option 1:
$ git reset --hard abc100
$ git push <origin> <branch>

Option 2:
$ git push -f <origin> abc100:<branch>
$ git reset --hard abc100

Filing this away as one more lifesaving tip!

Leave a comment