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

简介: Git - git 出现 fatal: refusing to merge unrelated histories 错误

背景


git pull失败,提示: fatal: refusing to merge unrelated histories

 

根本原因


因为两个根本不相干的 git 库, 一个是本地库, 一个是远端库, 然后本地要去推送到远端, 远端觉得这个本地库跟自己不相干, 所以告知无法合并

 

解决方案一


git clone远程仓库到本地,将需要推送的内容放到该仓库下 , 然后提交上去 , 这样算是一次update操作

 

解决方案二


使用强制命令

git pull origin master --allow-unrelated-historie

后面加上 --allow-unrelated-histories  , 把两段不相干的分支进行强行合;这里可能会进入一个编辑页面,只需要先ESC,然后敲:q! 即可

后面再push就可以了 git push -u origin master

相关文章
|
存储 安全 开发工具
深度解决 Git “fatal: refusing to merge unrelated histories” 错误解析什么是历史分支优雅草卓伊凡
深度解决 Git “fatal: refusing to merge unrelated histories” 错误解析什么是历史分支优雅草卓伊凡
1653 4
深度解决 Git “fatal: refusing to merge unrelated histories” 错误解析什么是历史分支优雅草卓伊凡
|
开发工具 git C++
【App Service】VS Code直接部署App Service时候遇见 “fatal: not a git repository (or any of the parent directories): .git”
通过VS Code发布Python App Service的时候,遇见了发布失败错误: The deployment failed with error: fatal: not a git repository (or any of the parent directories): .git . Please take a few minutes to help us improve the deployment experience
479 24
|
开发工具 git
Git版本控制工具合并分支merge命令操作流程
通过以上步聚焦于技术性和操作层面指南(guidance), 可以有效管理项目版本控制(version control), 并促进团队协作(collaboration).
3142 15
|
数据可视化 安全 开发工具
Git合并选Rebase还是Merge?弄懂这3点,从此不再纠结
本文深入解析了 Git 中 `rebase` 和 `merge` 的区别与使用场景。`merge` 保留完整历史,适合团队协作与公共分支合并;而 `rebase` 生成线性历史,适合本地分支整理与同步主分支。文章通过图示与代码示例,详细讲解了两者的工作原理、冲突处理方式及最佳实践,帮助开发者根据实际场景选择合适的合并策略,提升协作效率与提交历史可读性。
5099 1
|
API 开发工具 git
使用git pull遇到Automatic merge failed; fix conflicts and then commit the result.解决方案卓伊凡
使用git pull遇到Automatic merge failed; fix conflicts and then commit the result.解决方案卓伊凡
916 0
使用git pull遇到Automatic merge failed; fix conflicts and then commit the result.解决方案卓伊凡
|
网络协议 开发工具 git
解决 git 报错 “fatal: unable to access ‘https://github.com/.../.git‘: Recv failure Connection was rese
在使用 Git/Git小乌龟 进行代码管理的过程中,经常会遇到各种各样的问题,其中之一就是在执行 git clone 或 git pull 等操作时出现 “fatal: unable to access ‘https://github.com/…/.git’: Recv failure Connection was reset” 的报错。这个问题通常是由网络连接问题或代理设置不正确导致的。在我的个人使用经验中,我亲自尝试了四种方法,它们都能够有效地解决这个报错。个人比较推荐方法二。
11260 1
|
开发工具 git
git的rebase和merge的区别
通过这些内容和示例,您可以深入理解Git的 `rebase`和 `merge`操作及其区别,选择合适的方法进行分支管理,提高版本控制的效率和规范性。希望这些内容对您的学习和工作有所帮助。
3339 5
|
网络安全 开发工具 git
解决fatal:remote error:You can’t push to git://github.com/username/*.g
通过上述诊断与修复步骤,绝大多数的推送错误都能得到有效解决,确保您的Git工作流顺畅无阻。
1028 1
|
开发工具 git 开发者
|
Shell 网络安全 开发工具
fatal: unable to access 'https://github.com/wolfcw/libfaketime.git/': Encountered end of file
fatal: unable to access 'https://github.com/wolfcw/libfaketime.git/': Encountered end of file