【git】fatal: refusing to merge unrelated histories

这篇具有很好参考价值的文章主要介绍了【git】fatal: refusing to merge unrelated histories。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

在一次重新初始化本地仓库后,拉取远程仓库时提示:

fatal: refusing to merge unrelated histories

在“fatal: refusing to merge unrelated histories”(即,不知道彼此的存在,并已不匹配的项目提交历史)。

请考虑以下两种情况引发此错误:

您已经克隆了一个项目,并且.git目录以某种方式被删除或损坏。这导致Git不了解您的本地历史记录,因此,当您尝试向远程存储库中拉入或拉出远程存储库时,它将导致它引发此错误。

您已经创建了一个新的存储库,向其中添加了一些提交,现在您正尝试从已经具有自己的提交的远程存储库中提取信息。在这种情况下,Git也会抛出错误,因为它不知道两个项目之间的关系。

解决方案

通过切换allow-unrelated-histories开关可以解决该错误。在git pull或git merge命令之后,添加以下标记:文章来源地址https://www.toymoban.com/news/detail-672239.html

git pull origin master --allow-unrelated-histories

到了这里,关于【git】fatal: refusing to merge unrelated histories的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • git pull 提示错误 fatal: refusing to merge unrelated histories

    从远程拉项目到本地的时候提示错误 造成 fatal: refusing to merge unrelated histories错误的原因有以下几点: 有一个包含一些提交的新 Git 存储库。然后,您尝试从现有的远程仓库中提取。合并变得不兼容,因为分支和远程拉取的历史不同。当你试图合并两个完全不相关的分支时,

    2024年02月11日
    浏览(33)
  • 软件测试|Git:fatal: refusing to merge unrelated histories错误分析与解决

    问题介绍 在使用Git时,有时我们可能会遇到以下错误消息: 这个错误通常发生在尝试合并两个不相关的Git仓库历史时。在本文中,我们将详细解释为什么会出现这个错误以及如何解决它。 问题分析 这个错误的根本原因是Git无法确定两个不相关仓库的历史如何彼此关联。Gi

    2024年02月07日
    浏览(41)
  • 【Git】merge时报错:refusing to merge unrelated histories

    今天将feature分支合并到master时报错:refusing to merge unrelated histories(拒绝合并无关历史) 报错原因:当尝试从远程仓库\\\"gitee.com:zpg13/system_school\\\"的master分支拉取最新更新并合并到本地的master分支时,Git拒绝了这次合并,原因是两个分支拥有不相关的历史记录。 这种方法会保留

    2024年03月25日
    浏览(43)
  • idea使用git提交代码报异常refusing to merge unrelated histories和unknown option `allow-unrelated-histories‘

    目录  一、异常refusing to merge unrelated histories 二、异常unknown option `allow-unrelated-histories\\\' 使用git提交代码的时候报异常:refusing to merge unrelated histories 解决方法: 这个错误通常是因为两个不同的Git仓库被合并了,而且它们之间没有共同的祖先。这可能会发生在以下情况下: 你在

    2024年02月13日
    浏览(27)
  • 解决Git报错fatal: couldn‘t find remote ref –-allow-unrelated-histories 的解决办法

    当执行git中的“git pull origin master –allow-unrelated-histories”命令时, 如果出现 fatal: couldn\\\'t find remote ref –-allow-unrelated-histories 的错误,输入如下命令即可解决: git pull --rebase origin master git push origin master 点赞 -收藏-关注-便于以后复习和收到最新内容 有其他问题在评论区讨论-或

    2024年02月13日
    浏览(29)
  • 解决git报错:fatal: unable to access ‘xxx/‘: Failed to connect to 127.0.0.1 port 7890: Connection refused

    前言:Linux系统,使用vscode进行远程连接。 git push -u origin main 的时候,出现了如下问题: 无法连接到127.0.0.1 port 7890,连接被拒绝了。百度大法后基本上是取消代理即可: 但是我在终端中输入命令运行后,会出现一个红叉: 命令无法运行。 可能是之前设置过代理的名字不是

    2024年02月15日
    浏览(54)
  • 使用Git时 出现couldn‘t find remote ref-allow-unrelated-histories的解决办法

    当执行git中的“git pull origin master –allow-unrelated-histories”命令时,会出现“ couldn’t find remote ref –allow-unrelated-histories”的错误, 可以简单理解为我们的远程仓库与本地仓库的内容不对等造成的。 特别容易发生在 我们新建了一个文件夹,往git仓库中上传资料的ing况下,如下

    2024年02月11日
    浏览(36)
  • 【git】ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote r

    之前github的ssh的公私钥已经配置好,并可以正常使用,可没过多久,有一天突然报错: ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote repository. git 远程仓库两种协议:ssh,https。 在解决问题之前,先要了解git远程仓库的两种协议连接。 ssh协议连接gi

    2024年01月20日
    浏览(37)
  • git push 出现fatal: unable to access…not resolve host:…报错的多方面原因及解决方法 Merge branch 'master' of ...

    在git push -u origin \\\"master\\\"出现以下报错 fatal: unable to access  https://gitee.com.…….git/ : Could not resolve host: gitee.com.…… 在网上查阅、试了各种办法,都解决不了,最后发现自己有如下一些错误,也不知道哪一个导致了这样的结果,但是都更改后成功提交了。 1、我发现我刚注册的账

    2024年02月16日
    浏览(43)
  • ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote reposi...

    今天 github 提交代码时,git pull 出现错误:ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote repository。 可以使用 git push 把自己的代码提交到远程,但是不能 pull。这个情况之前没有遇到过。 这个报错信息翻译时:ssh:连接到主机github.com端口22:连接拒绝

    2024年02月13日
    浏览(452)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包