An error occurred when linking local code to the remote warehouse ! [rejected] master - master (non-fast-forward)error failed to push some refs to
Solution:
1.git init //初始化本地仓库
2.git remote add origin 远程仓库地址
3.git pull origin master 最重要的一步 remote add 后一定要先pull一下 不然push的时候会报错
4.git add ./
5.git commit -m "提交代码"
6.git push -u origin master
Finally you can submit it
Pitfalls : Because this is a newly built warehouse, I tried to push it, but in the end I got an
error error: The following untracked working tree files would be overwritten by
and Branch 'master' set up to track remote branch 'master' from 'origin '
git reset --hard FETCH_HEAD
git push -f origin master
I repeated these commands several times and still got an error.
Finally, I found that the remote new warehouse has a README.md file, and I also have one locally, but it seems that it will not be overwritten. So I
decisively deleted the local README.md file , and finally ran the above git command again and the submission was successful.