无法使用git subtree pull

7
我想把远程仓库的内容拉取到我的本地仓库中的一个文件夹中。使用以下命令时:git subtree pull --prefix my-local/folder my-remote master,我遇到了以下错误:fatal: refusing to merge unrelated histories。在另一篇文章中,我看到可以使用选项--allow-unrelated-histories,但是当我这样做时,我会得到error: unknown option --allow-unrelated-histories的错误信息(我把选项放在了最后)。我使用的是git版本2.10.1和Windows 10操作系统。非常感谢您提供任何帮助或想法来解决这个问题!

这个回答解决了你的问题吗?[Git子树错误“fatal:refusing to merge unrelated histories”]。 - Michael Freidgeim
2个回答

1

我也遇到过这个问题,后来加上了--squash选项就解决了。这个选项可以将子树的更改合并为一个提交。不确定为什么会起作用,但显然解决了历史问题。


“--squash选项”是什么意思?在脚本的哪个阶段执行该选项?使用“git pull old-repo master --allow-unrelated-histories”会出现“未知选项”错误,将--squash放在pull后面或最后都不起作用 - 我的Git版本是Windows 2010上的2.5.0。 - ASheppardWork
经过一番搜索,我发现需要添加以下额外步骤:1)git remote add old-repo <旧仓库目录>2)git subtree add --prefix=<旧仓库目录> old-repo master --squash3)git subtree pull --prefix=<旧仓库目录> old-repo master --squash4)git pull old master --allow-unrelated-histories - ASheppardWork

-1

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接