解决git push出现error: failed to push some refs to 错误

Posted poloyy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决git push出现error: failed to push some refs to 错误相关的知识,希望对你有一定的参考价值。

错误截图

技术图片

 

背景

  1. 码云上创建了空项目
  2. 本地项目绑定了远程仓库,尝试git push,然后报了错

 

解决办法

使用强制命令git pull origin master --allow-unrelated-historie 

后面加上  --allow-unrelated-histories , 把两段不相干的分支进行强行合;这里可能会进入一个编辑页面,只需要先ESC,然后敲 q! 即可, 或者根据它的页面提示如何操作可退出编辑页面即可

最后再push就可以了 git push -u origin master 

 

以上是关于解决git push出现error: failed to push some refs to 错误的主要内容,如果未能解决你的问题,请参考以下文章

Git push 报错 "error: failed to push some refs to " 解决

GIT用git push出现failed to push some refs to git...的解决方法

《Git与Github使用笔记》解决:git push error: failed to push some refs to XXX

《Git与Github使用笔记》解决:git push error: failed to push some refs to XXX

git 常见冲突解决——git push遇到报错error: failed to push some refs to ‘git@git.xxx.com:xxx/xxx.git

错误:error: failed to push some refs to 'https://github.com/pzq7025/KG.git'的解决办法