How to completely erase a git push from history?

153 views Asked by At

I accidentally pushed something I didn't want to to a repository. I followed the steps here but, although it did revert the code, there's still a log of what happened that I wish to erase: the log

To clarify, I want things to be as though everything after commit 1a869f3c6d simply never happened.

I have full access to the server where this repository is hosted, so I can manually modify some of the configuration files if necessary. And I don't know if this is really relevant, but the git server being used is Go Git Service.

Disclaimer: I understand why I may not want to do this. If you're only going to respond with why it's a bad idea, please don't.

1

There are 1 answers

1
Jonathon Reinhart On

To back out the latest commit on master, use git reset --hard:

git checkout master
git reset --hard master~1
git push -f

Or if you know the commit you want master to point to:

git reset --hard 1a869f3c6d