How do I resolve this issue? I am trying to commit but I get the below error.
git push origin monty_svm_dev
To [email protected]: ! [rejected] monty_svm_dev -> monty_svm_dev (non-fast-forward) error: failed to push some refs to '[email protected]:/mygit.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details. root@li409-202:~/mypath#
If you do a commit in one project and then accidentally push this commit, with bypassing code review, to another project, this will fail with the error message 'non-fast forward'. To fix the problem you should check the push specification and verify that you are pushing the commit to the correct project.
Git push rejected non-fast-forward means, this error is faced when git cannot commit your changes to the remote repository. This may happen because your commit was lost or if someone else is trying to push to the same branch as you. This is the error you face.
A non-fast-forward merge is a merge where the main branch had intervening changes between the branch point and the merge back to the main branch. In this case, a user can simulate a fast-forward by rebasing rather than merging. Rebasing works by abandoning some commits and creating new ones.
do git pull origin monty_svm_dev
first
What has happened is that the remote has more recent changes than your branch.
So before you can push
your changes, you need to get and merge the changes on the remote first.
You can do this either by doing a git checkout your_branch
, then:
git fetch origin your_branch
and then agit merge your_branch
or
git pull origin your_branch # fetch and merge in one operation
Where your branch is master, or your branch name (seems to be monty_svm_dev
in your case I think)
Once this is done (and any conflicts resolved) you can do a git push origin monty_svm_dev
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With