Tag Archives: ![rejected] master -> master(non-fast-forward) error:failed to push some refs to…

Git push error![rejected] master -> master(non-fast-forward) error:failed to push some refs to…

 

A project is created locally and a warehouse is created on GitHub. To link the local warehouse to the remote warehouse, I use the following method:
git init   initialize the local warehouse
git remote add origin XXX add the remote warehouse address
if you execute
git add – a after that,
Git commit – M ”
git push origin master, then this problem will appear (rejected), so after remote add, don’t worry about git add, be sure to git pull origin master, the reason for this is that you have readme files in the warehouse created by code cloud, but not locally, which causes local and remote out of sync,

Then there are two solutions:
Method 1:
if there is no local readme file, a local readme file will be generated

Git pull — rebase origin master local generation of readme files
git push origin master

Method 2:
then I will force the upload to cover the remote file,
git push – f origin master