I accidentally pushed a project to Git using git push when I intended to simply have it on my local repository (should've stopped after git commit).
I want to undo this git push such that the server repo goes back to a specific commit. I have looked at other questions such as this one, but the git push -f doesn't work for me and pulls up the error: To prevent you from losing history, non-fast-forward updates were rejected.
I even tried
git push -f origin CommitSHA:mainline
I thought the -f tag would force the push regardless of whether I was pushing a previous commit or not. How should I fix this error so that I can undo the git push?