push时git报错 error: failed to push some refs to 'git@gitee.com:git_zn/jianli.git' 解决办法

完整的错误提示以下git

To gitee.com:git_zn/jl.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@gitee.com:git_zn/jl.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

根据错误提示 用git pull 将远程仓库的内容pull下来github

无奈pull下来后再push仍是报上述错误bash

 

网上查找资料 找到了下面的解决办法fetch

在当前本地仓库下用git bash输入下面命令spa

git pull gitee master --allow-unrelated-histories

此时会有一个弹窗,提示你修改一个文档的内容,不用管他,按ESC键code

再按SHIFT+;  (SHIFT+;用来输入一个冒号)  再输入wq保存blog

:wq

 

接下来git会把远程仓库再pull一次rem

 

看到这个提示代表pull完成文档

 

再试试用it

 

 git push gitee master
  •  注意
    • git push gitee master  gitee是个人远程仓库名字已经被我修改了,默认的通常为origin

 

 

出现上面提示表示push到远程仓库成功

 


 

 上面的错误我只在码云上遇到过,在github上尚未遇到这样的问题,解决的办法应该和上面的相似

 


 

 

错误解决办法参考了廖雪峰老师的一篇文章: https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00150154460073692d151e784de4d718c67ce836f72c7c4000

相关文章
相关标签/搜索