简体   繁体   English

git子树覆盖多个目录

[英]git subtree covering multiple directories

I'm trying to use 15 directories from the rootdir of one git repo ("FOO") in a larger project. 我试图在一个较大的项目中使用一个git repo(“ FOO”)的rootdir中的15个目录。 Changes will be made to these files in the larger project and pulled back into the "FOO" repo. 将在较大的项目中对这些文件进行更改,并将其拉回到“ FOO”存储库中。 I logically want to git subtree split --rejoin those directories into a branch in "FOO" and then add/pull that branch up to the larger project. 我在逻辑上想git subtree split --rejoin这些目录重新加入“ FOO”中的一个分支,然后添加/拉出该分支直到更大的项目。 Said another way, I want to keep 1-2 directories private in the "FOO" repo and not add/sync them up to the larger project. 换句话说,我想在“ FOO”存储库中保留1-2个私有目录,而不要将它们添加/同步到更大的项目中。

However, when looking through the git docs and SO threads, it appears that this is not supported with git subtree split (see linked thread) unless I make each directory a subtree or I use git filter-branch to rewrite the history. 但是,在查看git docs和SO线程时,除非git subtree split 使用git filter-branch重写历史记录,否则这似乎不支持git subtree split (请参阅链接的线程)。 Git subtree and multiple directories Git子树和多个目录

Often git filter-branch is suggested as a solution but that appears to break any syncing back into the original "FOO" repo. 通常建议使用git filter-branch作为解决方案,但这似乎会中断所有同步回到原始“ FOO”存储库中的过程。 From git filter-branch --help : The rewritten history will have different object names for all the objects and will not converge with the original branch . git filter-branch --help重写的历史记录将为所有对象使用不同的对象名称,并且不会与原始分支收敛 Any changes to the "FOO" repo structure (like putting the 15 dirs under a new dir via filter-branch ) is not possible at this time. 目前无法对“ FOO”存储库结构进行任何更改(例如,通过filter-branch将15个dirs置于新目录下)。

Am I stuck with treating each directory as a subtree? 我是否坚持将每个目录视为子树? Doing 15 subtree splits in the larger repo (to sync back to "FOO" will take a significant amount of time. Are there any tricks to optimizing this (eg 1 pass through the large repo's commits but create a branch for each folder's commits)? 在较大的存储库中进行15个子树拆分(要同步回“ FOO”将花费大量时间。是否有任何技巧可以对此进行优化(例如,通过大型存储库的提交进行1次传递,但为每个文件夹的提交创建分支)?

You might want to use submodules. 您可能要使用子模块。 Please read: http://git-scm.com/book/en/v2/Git-Tools-Submodules 请阅读: http : //git-scm.com/book/en/v2/Git-Tools-Submodules

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM