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

时间:2023-03-08 16:54:45

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

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

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:

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

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

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

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

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

And another way is to force

git push origin master -f