Tag Archives: Solve git upload file error

Solve git upload file error [rejected] master -> master (fetch first) error: failed to push some refs to ‘

When push is executed, an error will be reported. The error code is as follows:

$ git push -u origin master
To gitee.com:backspacegit/aafdajs.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'gitee.com:backspacegit/aafdajs.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

This problem occurs because the readme.md file in GitHub is not in the local code directory. You can merge the code with the following command

git pull --rebase origin master

Then execute the statement

git push -u origin master

Done!