今天使用git提交到远程仓库时报错,报错如下:
error: failed to push some refs to ‘https://gitee.com/hxxx-d/gitstudy.git’
错误原因:
未将远程仓库克隆到本地
正确解决办法:
1.先与远程仓库建立连接
git remote add origin https://gitee.com/hxxx-d/gitstudy.git
2.git checkout master 切换到默认分支
3.然后使用 git pull origin master --allow-unrelated-histories 将远程仓库的master与本地仓库的进行合并。(–allow-unrelated-histories为强制合并,一定要加,否则无法拉取进行合并)
4. 最后再 git push origin master 进行远程推送。