I recently performed a hard reset
to another branch, as I was unable to get my master
branch back to a working state. I did this using the command:
git reset --hard masterBackupBeforeMerginDateDepositReceived04-01-2017
(i.e. to the branch where the particular feature I had broken was still working)
I then ran:
git commit -m 'commit after getting adds/omits working again'
having checked that the broken feature was working again on my local master
branch- it was, so I wanted to commit this again to be sure I had that working state saved.
I then ran
git push origin master
to push the master
branch to the server again, so that the now fixed feature should start working again on the live version. However, after running this push
, Git displayed a message I've not seen before:
To [email protected]:abc/xyz.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '[email protected]:abc/xyz.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
It seems that Git is not happy with me pushing an 'old' version to the server, when there is a 'newer' version currently on the server... How can I force the server to accept my push
of the 'old' version (which is currently the master
branch on my local machine?
simply add the force option
-f
git push -f origin master
Git Push Documentation