How can I delete a commit which I already pushed to the remote? I got an answer to delete my latest commit. In the answers of this Stack Overflow post someone said to do git reset --hard HEAD~1
to delete the latest commit. I did that and it worked but now when I push to the remote, it gives me this error
To github.com:an4s911/login-system.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'github.com:an4s911/login-system.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
it says to pull before pushing, so I pulled. But now I have the deleted commit back. How do I solve this problem?