美文网首页Git使用git及github学习Git的基本用法
Git:推送到码云时报错,无法push和pull,failed

Git:推送到码云时报错,无法push和pull,failed

作者: 红尘_漫步 | 来源:发表于2019-06-14 16:03 被阅读0次

本地库进行更改后,需要推送更新到码云

输入:git push gitee master

没有推送成功,报错如下:

! [rejected] master -> master (non-fast-forward)

error: failed to push some refs to 'git@gitee.com:XXX/XXXXt.git'

hint: Updates were rejected because a pushed branch tip is behind its remote

hint: counterpart. Check out this branch and 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 先拉取,仍然报错:refusing to merge unrelated histories

查了一下,有人说是因为本地仓库和远程仓库是两个仓库导致的,需要在 git pull命令后面使用

--allow-unrelated-history,告诉系统运行合并不相关的历史内容

输入git pull gitee master --allow-unrelated-histories

输入说明,然后esc, :wq  回车

再次输入:git push gitee master

则可以推送成功。

相关文章

网友评论

    本文标题:Git:推送到码云时报错,无法push和pull,failed

    本文链接:https://www.haomeiwen.com/subject/jfrpfctx.html