Git提交到GitHub报错:Updates were rejected because the remote contains work that you do not have locally

转自:https://blog.csdn.net/u011284073/article/details/81609707 

在使用Git将本地项目上传到GitHub上时,键入命令:

git push -u origin master
报错提示:Updates were rejected because the remote contains work that you do not have locally,This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes (e.g., 'git pull ...') before pushing again.

究其原因,是因为本宝宝在GitHub上创建远程仓库时,勾选了 Initialize this repository with a README这项,导致远程仓库不为空,解决办法,先将远程仓库的内容合并到本地,然后再上传即可,命令如下:

git pull --rebase origin master
git push -u origin master
 
 

猜你喜欢

转载自blog.csdn.net/qq_29985391/article/details/85047841