【问题标题】:subtree merge claims already up-to-date子树合并声明已经是最新的
【发布时间】:2015-06-23 21:10:34
【问题描述】:

我没有太多运气从子树中推送/拉取更改。通常我使用“git subtree”命令来创建子树并拉取更改。拉动时,我需要解决蹩脚的冲突(当确实没有冲突时),而推动永远不起作用。

所以今天我尝试了一种不同的方法,使用子树合并而不是 git subtree 命令。我按照https://help.github.com/articles/about-git-subtree-merges/ 的说明进行操作。

首先,我创建要用作子树的存储库的远程:

git remote add -f cumulonimbus-machine http://github.com/fschwiet/cumulonimbus-machine
git merge -s ours --no-commit cumulonimbus-machine/old
git merge -s ours --no-commit cumulonimbus-machine/fschwiet

“旧”分支是“fschwiet”分支的父级。我最初想将子树建立在“旧”的基础上,这样我就可以测试拉动更改(拉动“fschwiet”的其余部分)。无论如何,我创建了子树:

git read-tree --prefix=host/ -u cumulonimbus-machine/old

这很好用。所有文件都在 hosts 文件夹中,我可以按预期看到它的旧分支。然后我尝试获取一些更新:

git pull -s subtree cumulonimbus-machine fschwiet

我得到了一些令人失望的输出:

From http://github.com/fschwiet/cumulonimbus-machine
 * branch            fschwiet   -> FETCH_HEAD
Already up-to-date

我预计最后一次拉取会更新主机目录以获取来自“fschwiet”分支的最新信息。但它并没有拉倒任何东西。我确实验证了“旧”和“fschwiet”实际上不是同一个提交。我尝试了一些其他方法,结果相同:

git subtree merge --prefix=host cumulonimbus-machine/fschwiet
git merge -X subtree=host cumulonimbus-machine/fschwiet
git subtree pull --prefix=host cumulonimbus-machine 90686ba2d0c31afdc516611064
git subtree pull --prefix=host cumulonimbus-machine master

我错过了什么?

【问题讨论】:

    标签: git git-subtree


    【解决方案1】:

    我的错误是在跑步中

    git merge -s ours --no-commit cumulonimbus-machine/fschwiet
    

    之前

    git read-tree --prefix=host/ -u cumulonimbus-machine/old
    

    这创建了一个合并提交,拉入“旧”分支的内容,但告诉存储库它与“fschwiet”分支同步。

    尽管如此,我确实学到了一些有价值的东西。如果我使用,似乎我遇到的一些合并问题可能会得到解决

    git merge -X subtree=host cumulonimbus-machine/fschwiet
    

    而不是 git merge -s subtree 或 git subtree merge。这似乎做了一个更智能的合并算法。特别是,它删除了已删除的文件(与 git subtree merge 不同)。

    【讨论】:

      猜你喜欢
      • 2014-11-11
      • 2021-12-01
      • 1970-01-01
      • 2020-10-30
      • 2011-12-24
      • 1970-01-01
      • 1970-01-01
      • 2018-11-27
      • 1970-01-01
      相关资源
      最近更新 更多