当前位置: 移动技术网 > IT编程>脚本编程>Python > push时git报错 error: failed to push some refs to 'git@gitee.com:git_zn/jianli.git' 解决办法

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

2018年08月22日  | 移动技术网IT编程  | 我要评论

街角的祝福简谱,dnf无敌,日文字体

完整的错误提示如下

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下来

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

 

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

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

git pull gitee master --allow-unrelated-histories

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

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

:wq

 

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

 

看到这个提示表明pull完成

 

再试试用

 

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

 

 

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

 


 

 上面的错误我只在码云上遇到过,在github上还没有遇到这样的问题,解决的办法应该和上面的类似

 


 

 

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

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网