How the problem solved about " Dealing with non-fast-forward errors"

Recently ,I got confused When I use  git to push one of my project. The problem is below:

And I Found the solutions  below maybe helpful to someone who meet the problem:

Dealing with non-fast-forward errors

Sometimes, Git can't make your change to a remote repository without losing commits. When this happens, your push is refused.

If another person has pushed to the same branch as you, Git won't be able to push your changes:

You can fix this by fetching and merging the changes made on the remote branch with the changes that you have made locally:

Or, you can simply use git pull to perform both commands at once:

And another way is to force

git push origin master -f
原文地址:https://www.cnblogs.com/xiyin/p/6099332.html