How to deal with non-fast forward errors

+1 vote
Jul 3, 2018 in Other DevOps Questions by Tyrion anex
• 8,690 points

1 answer to this question.

+1 vote

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.

$ git push origin master


! [rejected]   master -> master (non-fast-forward)

error: failed to push some refs to ''

To prevent you from losing history, non-fast-forward updates were rejected

Merge the remote changes (e.g. 'git pull') before pushing again.  See the

'Note about fast-forwards' section of 'git push --help' for detail

This can be fixed by fetching and merging the changes made on the remote branch with the changes that you have made locally. Run the following commands to fetch and merge.

$ git fetch origin

This command fetches the updates made to a remote repository.

$ git merge origin YOUR_BRANCH_NAME

This command merges the updates made online with your local work.

answered Jul 3, 2018 by Sophie may
• 10,590 points
try this

git pull --rebase origin master
Hi, I am facing this same issue. I'll try

git pull --rebase origin master

But can you explain what this command does?

If you pull remote changes with the flag --rebase, then your local changes are reapplied on top of the remote changes.

Related Questions In Other DevOps Questions

0 votes
1 answer
0 votes
0 answers
0 votes
1 answer

How to get issues count based on rules in a sonar project?

There are API docs in the footer ...READ MORE

answered May 4, 2018 in Other DevOps Questions by DareDev
• 6,890 points
0 votes
1 answer

How to get results of SonarQube?

You can use sonarqube quality gates which ...READ MORE

answered Jun 8, 2018 in Other DevOps Questions by ajs3033
• 7,280 points
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
+2 votes
1 answer
Send OTP
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP