首页 > 其他分享 >解决Git中fatal: refusing to merge unrelated histories

解决Git中fatal: refusing to merge unrelated histories

时间:2022-09-19 18:59:09浏览次数:54  
标签:Git git refusing histories merge unrelated fatal

Git的报错
在使用Git的过程中有时会出现一些问题,那么在解决了每个问题的时候,都需要去总结记录下来,下次不再犯。

一、fatal: refusing to merge unrelated histories
今天在使用Git创建项目的时候,在两个分支合并的时候,出现了下面的这个错误。

~/SpringSpace/newframe on  master ⌚ 11:35:56
$ git merge origin/druid
fatal: refusing to merge unrelated histories

~/SpringSpace/newframe on  master ⌚ 11:35:56
$ git merge origin/druid
fatal: refusing to merge unrelated histories

这里的问题的关键在于:fatal: refusing to merge unrelated histories

你可能会在git pull或者git push中都有可能会遇到,这是因为两个分支没有取得关系。那么怎么解决呢?

二、解决方案
在你操作命令后面加--allow-unrelated-histories
例如:
git merge master --allow-unrelated-histories

~/SpringSpace/newframe on  druid ⌚ 11:36:49
$ git merge master --allow-unrelated-histories
Auto-merging .gitignore
CONFLICT (add/add): Merge conflict in .gitignore
Automatic merge failed; fix conflicts and then commit the result.

~/SpringSpace/newframe on  druid ⌚ 11:36:49
$ git merge master --allow-unrelated-histories
Auto-merging .gitignore
CONFLICT (add/add): Merge conflict in .gitignore
Automatic merge failed; fix conflicts and then commit the result.

 如果你是git pull或者git push报fatal: refusing to merge unrelated histories

同理:
git pull origin master --allow-unrelated-histories
等等,就是这样完美的解决咯!
————————————————
版权声明:本文为CSDN博主「向小凯同学学习」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/wd2014610/article/details/80854807

标签:Git,git,refusing,histories,merge,unrelated,fatal
From: https://www.cnblogs.com/shiding/p/16708663.html

相关文章

  • git中Updates were rejected because the tip of your current branch is behind解决
     1.错误说明出现这个错误的原因是git本地仓库的当前版本低于远程仓库的版本(大白话就是:你在github上进行的修改没有同步到本地git仓库中)。2.错误原因第一种错误的原......
  • 初始化gitlab仓库
    初始化gitlab仓库一、Git全局设置gitconfig--globaluser.name"yourgitlabusername"gitconfig--globaluser.email"yourgitlabuserpassword"二、创......
  • qt creator 使用 git
    创建仓库在github,gitee这样的平台上,创建一个仓库,注意不要初始化仓库配置项目创建项目的时候,cvs选择git工具。tool->git->remoterepo->manageremote,......
  • 使用docker安装gitlab
    1.dockerpullgitlab/gitlab-ce2.[root@localhostgitlab_docker]#catdocker-compose.ymlversion:'3.8'services: gitlab:   image:'gitlab/gitlab-ce:lates......
  • 集成部署 2-jenkins获取git轮询查询
    一:配置  二:构建任务配置中配置git     三:轮询查询最后保存     看git拉取本地成功  ......
  • 解决git推送失败的问题
    解决git推送失败的问题报错:error:srcrefspecmasterdoesnotmatchany 暴力方法: 1,把本地文件夹的.git文件夹删除; 2,初始化本地仓库......
  • TortoiseGit 在windows11 中使用,建议升级到 2.13.0版本以后
                   ......
  • GitHub不再支持密码验证解决方案:SSH免密与Token登录配置
    今天提交代码,push到GitHub上,突然出现这个问题。remote:SupportforpasswordauthenticationwasremovedonAugust13,2021.Pleaseuseapersonalaccesstokenins......
  • git
    1.git介绍免费、开源的分布式版本控制系统(版本控制就是记录变化过程)从个人开发过度到团队协作。集中式版本控制系统:SVN好处:易于管理缺点:中央......
  • 学会小知识 git拉项目提交项目
    win+tab 就可以看到多少页面在运行。白天写草稿,晚上记笔记。git拉项目提交项目。git拉项目如果git还不熟练建议先用sourcetree先用起来 gitbash啊  gitbran......