This is usually caused by another repository pushing to the same ref

  1. 新闻资讯
  2. 技术百科
公司新闻 案例分享 技术百科 行业动态

This is usually caused by another repository pushing to the same ref

来源:奇站网络 浏览量:4804 发布日期: 2020-06-30

  1. git push origin master

报错

error: failed to push some refs to ‘’
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.

执行如下命令试图更新远程仓库的内容

  1. git pull origin master

报错refusing to merge unrelated histories(拒绝合并不相关的历史)

原因

本地仓库和远程仓库实际上是两个仓库。
远程仓库初始化后自动创建了README.md
本地仓库是以git init的方式初始化,没有包含README.md,直接git add . git commit提交本地的文件。

这样导致两边仓库的提交不一样

解决方法1

  1. git pull origin master --allow-unrelated-histories

解决方法2

远程分支上存在本地分支中不存在的提交,往往是多人协作开发过程中遇到的问题,可以先fetch再merge,也就是pull,把远程分支上的提交合并到本地分支之后再push。

如果你确定远程分支上那些提交都不需要了,那么直接git push origin master -f,强行让本地分支覆盖远程分支。。。

标签:

厦门奇站网络科技有限公司

电话:13313868605

QQ:3413772931

地址:厦门集美区软件园三期

网站地图


                    扫一扫加我咨询