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
I'm using this group of commands to reset my remote repo, this will re-initialize your local repo and relink with your remote repo then force push the updates.
I think this way won't work in your case, but may be useful for someone else
go to the source folder then run the commands :
note that https://github.com/*.git
is your remote repo link
git init
git remote add origin https://github.com/*.git
git add .
git commit -m "initial commit"
git push origin master -f
git push --set-upstream origin master
**Note: this will clear all your git history on your master branch**
The message means that you're not allowed to do non-fast-forward push.
Your remote repository has most likely denyNonFastforwards = true
in its config. If you change that, git push --force
should work.
To change the setting, you need access to the machine with the remote repository. From there, do git config receive.denynonfastforwards false
.
You're not allowed to do git push that is not fast-forward.
If the remote is GitHub, go to https://github.com/$USER/$REPO/settings/branches
and un-protect the branch in question.
You have to be admin of the repo to do that.
If the remote is your own git server, run git config receive.denynonfastforwards false
there.
Try using the -f
flag and putting it after the remote branch name.
git push origin master -f