I’m trying to undo some changes that have already been pushed to a remote repository, and I’ve done so locally with
git reset --hard COMMIT-HASH
But now it won’t let me push without pulling first, which of course defeats the purpose. I’ve tried:
git push -f
Which errors out with:
Total 0 (delta 0), reused 0 (delta 0)
remote: error: denying non-fast-forward refs/heads/master (you should pull first)
To git@xxx.beanstalkapp.com:/yyy.git
! [remote rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@xxx.beanstalkapp.com:/yyy.git'
So how do I get my new, correct version of the branch to the remote?
From the
git configman page:The server you are trying to push to has this setting enabled. So, short answer, is that in this case you will not be able to
git push --force.To get the correct version of the branch to the remote, you will have to make a new commit to the tip of the branch that gets it to the correct state. If you are currently at the commit for the correct state, you can run the following: