git doesn't (by default) allow you to push to a branch anything that "rewinds" the branch tip. In other words, if the current branch head is not a direct parent or ancestor of the branch tip then the push will be refused.
You can try to push anyway by using the -f
option to git push
or by using a refspec with a leading '+', e.g. git push origin +mybranch:mybranch
.
Usually remote repositories will still not let this happen because you risk losing commits if different people can indiscriminately push branch tips that don't include commits that they don't have locally.
You can override this behaviour by changing the configuration parameter receive.denyNonFastForwards
on the remote repository (assuming that you have the appropraite access to the remote repository).
If you don't have such access you may be able to achieve this by deleting the remote branch and recreating it.
e.g.
git push origin :mybranch
git push origin mybranch
Note that more recent versions of git include a configuration parameter receive.denyDeletes
that will, if set, prevent this potentially dangerous workaround from working.