【问题标题】:Can't use git subtree pull不能使用 git subtree pull
【发布时间】:2016-10-28 15:47:14
【问题描述】:

我正在尝试从远程提取到我的存储库中的文件夹。使用时:

git subtree pull --prefix my-local/folder my-remote master

我收到以下错误:

fatal: refusing to merge unrelated histories

我在另一个post 中读到我可以使用选项--allow-unrelated-histories,但是当我这样做时,我得到error: unknown option --allow-unrelated-histories (我把选项放在最后)

我使用的是 git 版本 2.10.1 和 Windows 10

非常感谢任何有关如何推进此项目的帮助或想法!

【问题讨论】:

标签: git git-subtree


【解决方案1】:

我遇到了同样的问题,我通过添加 --squash 选项让它工作。此选项将子树更改合并为单个提交。我不确定为什么会这样,但它显然解决了历史问题。

【讨论】:

  • 您所说的 --squash 选项是什么意思?你在脚本的什么时候这样做?使用: git pull old-repo master --allow-unrelated-histories 出现“未知选项”错误,并且在 pull 或最后放置 --squash 不起作用 - 我的 git 版本在 windows 2010 上是 2.5.0跨度>
  • 经过一番挖掘后我发现 - 我不得不添加这些额外的步骤--- 1) git remote add old-repo 2) git subtree add --prefix= old-repo master --squash 3) git subtree pull --prefix= old-repo master --squash 4) git pull old master --allow-unrelated-histories
【解决方案2】:

试试sudo add-apt-repository ppa:git-core/ppa && sudo apt-get update 然后使用--allow-unrelated-histories

【讨论】:

    猜你喜欢
    • 2015-04-20
    • 2014-12-01
    • 2013-02-11
    • 1970-01-01
    • 2014-05-06
    • 2014-03-09
    • 1970-01-01
    • 2022-10-13
    • 2012-07-29
    相关资源
    最近更新 更多