How to deal with non-fast forward errors

+1 vote
Jul 3, 2018 in Other DevOps Questions by Tyrion anex
• 8,700 points
31,251 views

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

To https://github.com/USERNAME/REPOSITORY.git

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

error: failed to push some refs to 'https://github.com/USERNAME/REPOSITORY.git'

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,620 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?

Thanks
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

How to integrate OnPrem Azure DevOps Server with the cloud one?

When I go to Project > Boards ...READ MORE

answered Feb 11, 2022 in Other DevOps Questions by Bhavitha
• 1,000 points
617 views
0 votes
0 answers

How to login to Azure Devops organization using non-microsoft account?

I created an Azure DevOps organization and ...READ MORE

Mar 28, 2022 in Other DevOps Questions by Kichu
• 19,040 points
1,138 views
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
2,843 views
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,300 points
3,055 views
+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
4,035 views
+2 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP