解决Git中fatal: refusing to merge unrelated histories
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
1 2 3 | ~/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.
1 2 3 4 5 | ~/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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Ollama——大语言模型本地部署的极速利器
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现