Our remote master branch somehow got messed up. Current development code is on the master branch along with the latest commits. Obviously, the development code is not ready for the master branch.
So on my local repository, I did a reset to the latest tag, git reset --hard (Tag)
. The master branch is now correct on my local repository. Now when I try to push the changes on to the remote repository, git push origin master
, I get an error:
To (REMOTE GIT REPOSITORY LOCATION)
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '(REMOTE GIT REPOSITORY LOCATION)'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
So after looking around I found out the --force
option. So I did a force push on to the remote repository, git push --force origin master
, and I still got an error:
Total 0 (delta 0), reused 0 (delta 0)
remote: error: denying non-fast-forward refs/heads/master (you should pull first)
To (REMOTE GIT REPOSITORY LOCATION)
! [remote rejected] master -> master (non-fast-forward)
error: failed to push some refs to '(REMOTE GIT REPOSITORY LOCATION)'
I can't do a pull on master, because it contains development code which can't be on master.
denyNonFastforwards = true
. I changed it to false, pushed my changes and then changed it back to true. Thanks again everyone, for the help. – Unadvisedrefs/heads/
is not allowed. This can be a tag (if annotated). You can dogit push -f origin mytag^0:main
to push the commit the tag points to instead. That will work. – Stockton