Git fatal: refusing to merge unrelated histories

$ git pull origin master
From gitee.com:zrxisme/testLog
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

原因:
使用pull操作的时候出现以上错误,原因很简单,你提交的内容和远程仓库里的内容不同的,有些小伙伴很奇怪,我明明从远程仓库clone下来的,为什么说是两个不同的内容呢?其实这是新手经常犯的一个错误,大多数情况都是由于在提交的时候重复使用了git init操作,这导致重新生成了一个新的git文件夹,之前的git文件夹被覆盖,所有之前提交的历史被清空,所以当我们clone项目的时候,重新编写提交切记不要使用git init操作

解决办法:
 执行以下操作git pull origin master --allow-unrelated-histories,执行后悔打开一个vi文本编辑器输入:wq!退出即可,

然后重新提交,你会发现成功了

原文链接:https://blog.csdn.net/qq_41966938/article/details/79854515

原文地址:https://www.cnblogs.com/yangfei123/p/12536482.html

时间: 2024-08-03 18:50:59

Git fatal: refusing to merge unrelated histories的相关文章

GIt -- fatal: refusing to merge unrelated histories 问题处理

今晚碰到这个问题-- fatal: refusing to merge unrelated histories 想了一下,为什么就这样了? 因为我是先本地创建了仓库,并添加了文件,然后再到github网上建仓库,项目名称一样的,这样一来当我想关联远程仓库,提交代码就报错了 解决方法 $ git pull origin master --allow-unrelated-histories --allow-unrelated-histories 参数的意思是合并仓库的时候,允许不相关的历史的提交内容

Git:fatal: refusing to merge unrelated histories

如何去解决fatal: refusing to merge unrelated histories 先pull,因为两个仓库不同,发现refusing to merge unrelated histories,无法pull 因为他们是两个不同的项目,要把两个不同的项目合并 git需要添加一句代码,然后再git pull 这句代码是在git 2.9.2版本发生的 最新的版本需要添加 --allow-unrelated-histories 假如我们的源是origin,分支是master,那么我们需要

git 出现 fatal: refusing to merge unrelated histories 错误

git pull 失败 ,提示:fatal: refusing to merge unrelated histories 其实这个问题是因为 两个 根本不相干的 git 库, 一个是本地库, 一个是远端库, 然后本地要去推送到远端, 远端觉得这个本地库跟自己不相干, 所以告知无法合并 具体的方法, 一个种方法: 是 从远端库拉下来代码 , 本地要加入的代码放到远端库下载到本地的库, 然后提交上去 , 因为这样的话, 你基于的库就是远端的库, 这是一次update了 第二种方法: 使用这个强制的方

android studio提交到开源git时出现:fatal: refusing to merge unrelated histories的解决办法

创建本地库和fetch远程分支这些前面的步骤这里略过.可以自行百度. 解决办法: 1.cmd进入项目的根目录. 2.执行下面的命令:git pull origin master --allow-unrelated-histories.可以提交成功. 3.再次push. 有其它的好办法,欢迎建议. 原文地址:https://www.cnblogs.com/xiangxinhouse/p/8254120.html

Git 报错:fatal: refusing to merge unrelated histories

背景:[接上篇git push 出错的随笔]当 pull 远端仓库到本地的时候,出现以下错误: 错误情况: 出错原因:主要原因还是在于本地仓库和远程仓库实际上是独立的两个仓库,假如我之前是直接以 clone 的方式在本地建立起远程 github 仓库克隆的本地仓库就不会有这个问题了. 解决方式:可以在 pull 命令后紧接着使用 --allow-unrelated-history 选项来解决问题(该选项可以合并连个独立启动仓库的历史) $ git pull origin master --all

git无法pull仓库refusing to merge unrelated histories

http://blog.csdn.net/lindexi_gd/article/details/52554159 本文讲的是把Git在最新2.9.2,合并pull两个不同的项目,出现的问题如何去解决fatal: refusing to merge unrelated histories 我在Github新建一个仓库,写了License,然后把本地一个写了很久仓库上传. 先pull,因为两个仓库不同,发现refusing to merge unrelated histories,无法pull 因为

git merge合并时遇上refusing to merge unrelated histories的解决方案

如果git merge合并的时候出现refusing to merge unrelated histories的错误,原因是两个仓库不同而导致的,需要在后面加上--allow-unrelated-histories进行允许合并,即可解决问题 如果还不能解决问题,就把本地的remote删除,重新git remote add添加远程仓库,再按上面的方法来,问题解决. git checkout master #切换到要提交代码的分支 git pull origin master --allow-unr

解决Gi合并分支refusing to merge unrelated histories错误

本文不再更新,可能存在内容过时的情况,实时更新请移步我的新博客:解决Gi合并分支refusing to merge unrelated histories错误: 背景: 有两个仓库,分别为A(github.com)和B(gitlab.com),在这两个仓库分别有两个相同名字的项目p(除名字外不存在任何关系),然后我想把本来在本地的A仓库的p项目代码,提交到B仓库.我的思路是,现在本地创建新分支dev,然后将地址修改为B仓库的远程地址,然后尝试pull代码,提示出错:refusing to mer

Git报错-refusing to merge unrelated histories

执行git pull 时报错: 出现这个问题的最主要原因还是在于本地仓库和远程仓库实际上是独立的两个仓库.假如我之前是直接clone的方式在本地建立起远程github仓库的克隆本地仓库就不会有这问题了. 可以在pull命令后紧接着使用--allow-unrelated-history选项来解决问题(该选项可以合并两个独立启动仓库的历史). 命令: $git pull origin master –allow-unrelated-histories 以上是将远程仓库的文件拉取到本地仓库了. 原文地