If you accidentally committed something you shouldn’t have, and pushed it to Github, there are still ways to delete or modify it.
You can do an interactive rebase, which is useful if the commit isn’t the most recent one. If the commit was, for example, 12 commits ago, you can rebase from then, remove the offending commit, and save.
git rebase -i HEAD~12
A list with the commits will be displayed in an editor.
On each line replace pick
with drop
to remove the commit from the history.
Press Ctrl+C
to exit. Then enter :wq
to save the changes.
Once your local repo is in working order, you can force push to Github.
git push origin master --force