【问题标题】:git-subtree checkout specific folder under other namegit-subtree 以其他名称签出特定文件夹
【发布时间】:2016-04-27 15:38:36
【问题描述】:

您好,我正在尝试设置一个带有两个上游的 git-repo。

  • upstream-jointswp: (https://github.com/JeremyEnglert/JointsWP/)

    • 整个根文件夹 / 转到我位于根 / 的存储库。 (没问题)
  • upstream-woocommerce: (https://github.com/woothemes/woocommerce)

    • 此存储库 /templates 的子目录应位于我的存储库中的 /woocommerce 下。
    • 我能够通过使用 sparseCheckout 实现 /templates 在我的存储库中作为唯一的文件夹/树。
    • 我尝试使用 git-subtree 来跟踪提交。

当我使用 git-subtree 时。如何将 /templates 中的内容从我的上游签出到我的 repo 中的 /woocommerce?

如果我的问题不像我希望的那样直截了当,请给我一个标志;)

【问题讨论】:

    标签: git git-subtree


    【解决方案1】:

    您应该将split 和add 结合起来。

    因此,您克隆了您想要参与的项目,然后在其中创建一个包含templates/ 的分支。即

    git subtree --prefix=templates/ split -b templates_only
    

    然后你可以使用来自另一个 repo 的分支:

    git subtree --prefix=woocommerce/ add ../woocommerce_clone/.git templates_only
    

    【讨论】:

    • 感谢您的回复。这行得通。但是从性能方面来看是一种痛苦。子目录中有 5k+ 次提交被重新散列。拆分需要很长时间。有没有办法加快速度或者我应该使用 git-submodule 代替?
    • @termnml 子模块能做到吗?我怀疑。据我了解,您别无选择,拆分应该通过所有提交并查看其中哪些会影响子目录。 split 唯一的好处 - 你只需要做一次,然后你可以更快地拉/推子树。
    • 非常感谢您的提醒。 ;)
    猜你喜欢
    • 2017-03-09
    • 1970-01-01
    • 2017-05-31
    • 2016-07-08
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 2019-04-29
    • 1970-01-01
    相关资源
    最近更新 更多