How to Solve Error: failed to push some refs to git

$ git push -u origin master
To [email protected]:yangchao0718/cocos2d.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to ‘[email protected]:yangchao0718/cocos2d.git
hint: Updates were rejected because the tip of your current branch is behin
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull …’) before pushing again.

The main reason for the error is that the README.md file in github is not in the local code directory
You can merge the code with the following command [Note: pull=fetch+merge]
git pull –rebase origin master
After executing the above code, you can see that the README.md file is added to the local code base
At this point, you can upload the code to github by executing git push -u origin master

Similar Posts: