Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push failed, "Non-fast forward updates were rejected"

Tags:

git

github

push

I've edited my GIT repositories via Git Online. After I tried to push my local code changes, I got an error:

Git push failed, To prevent from losing history, non-fast forward updates were rejected. 

How can I fix this?

like image 385
Sarath Avatar asked Aug 01 '11 11:08

Sarath


People also ask

How do you resolve a non-Fast-Forward rejection?

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.

What does rejected non-fast-forward mean in git?

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.

How do I force git push?

To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch).


1 Answers

Pull changes first:

git pull origin branch_name 
like image 138
iafonov Avatar answered Nov 08 '22 13:11

iafonov