How to Solve Git Error: error: failed to push some refs to……

Error message:

error: failed to push some refs to '[email protected]:....." Updates were rejected because the remote contains work that you do not have locally.
This is usually caused by another repository pushing to

Cause analysis:

1. This error may occur when using git to push the source code to GitHub

2. The main reason for the error is that the readme.md file in GitHub is not in the local code directory

Solutiont:

Method 1: pull it down first and it will merge automatically (don’t worry)

Command: git pull origin master

Method 2: Code merging can be carried out through the following commands

Command: git pull — rebase origin master (my successful solution is method 2)

Finally, execute the statement git push to upload the code to GitHub

Command: git push – U origin master

Read More: