git报错error: failed to push some refs to ‘https://

An error is reported when submitting to the remote warehouse:
Insert picture description here

Solution:

git remote rm origin//先移除和远程仓库的连接
git remote add origin 远程仓库地址 //连接远程仓库,创建主分支
git pull origin master//把本地仓库的变化连接到远程仓库主分支

An error may be reported in the third step, because the local warehouse and the remote warehouse are actually two independent warehouses, and you need to merge the two warehouses first (if the local warehouse is cloned directly from the remote warehouse, there is no problem)

git pull origin master --allow-unrelated-histories//只是合并在了本地仓库
git push -u origin master//提交到远程仓库

Guess you like

Origin blog.csdn.net/qq_41363459/article/details/112300456