I’m not really familiar with how git works. I pushed a commit by mistake and want to revert it. I did a
git reset --hard HEAD~1
Beware Fellow Googlers: This does not only revert the commit, but discards all file changes!
and now the project is reverted on my machine, but not on github. If I try to push this code, I get the error ‘Your branch is behind ‘origin/master’ by 1 commit, and can be fast-forwarded.’ How do I remove this commit from github?
You can do
git push --forcebut be aware that you are rewriting history and anyone using the repo will have issue with this.If you want to prevent this problem, don’t use reset, but instead use
git revert