与单个子模块的多个回购 [英] Multiple repos with single submodule

查看:91
本文介绍了与单个子模块的多个回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查找了一段时间,没有找到答案(也许我不知道该看什么)。



我们有一个主库这是它自己的仓库(我们称之为Lib)它包含了我们大部分的模块和子模块。
我们还可以说它的大小为2GB ...

现在我们有很多项目,比如:ProjA,ProjB,ProjC,每一个都使用Lib作为子模块。


ProjA


  • Lib (分支机构:master,commit#:1)


    ProjB


    • Lib(分支:other,commit#:2)

      $ b $ ProjA


      • Lib(分支:master,提交#:4)

        $ /

        $ b

        因此,尽管我能够保持每个项目的引用都是正确的库(aka子模块)版本。我有3 * 2GB = 6GB的相同子模块。



        有没有一种方法可以引用单个子模块,同时保持正确的文件/版本引用?



        例如


        ProjA


        • Lib / base_lib.h(v1.0)

        • Lib / file_only_in_this_commit




        ProjB


        • Lib / base_lib.h (v1.0)


        ProjC


        • Lib / base_lib.h(v1.1)


        谢谢!

        $ b您可以使用 git worktree (自git 2.5开始可用)为Lib创建额外的工作区子模块,在ProjA,ProjB等内部的位置。

        因为 git worktree 具有相同名称的工作树(全部称为Lib),我刚创建了一个脚本,share_submodules 来解决困难并创建额外的工作树而不是子模块,将其设置为正确的子模块提交,并为共享模块中的所有子模块递归地执行。



        它应该可以工作,如果子模块是由 git子模块更新创建的--init --recursive ,除了所有副本都引用一个模块的对象。



        如果您通过删除子模块转换到它,您的 .git 中存在杂散子模块文件,并且我创建了 find_stray_submodules.py 清理它们。


        I've looked for a while and didn't find answer (maybe I don't know what to look).

        We've got a main library which is a repository by it self (let's call it Lib) it contains most of our modules and submodules. Let's also say it has a size of 2GB...

        Now we've got many projects such as: ProjA,ProjB,ProjC each one uses the Lib as submodule.

        ProjA

        • Lib (branch:master,commit#:1)

        ProjB

        • Lib (branch:other,commit#:2)

        ProjA

        • Lib (branch:master,commit#:4)

        So while I'm able to keep every project referencing to correct library (aka submodule) version. I've got now 3*2GB = 6GB of THE SAME submodule.

        Is there a way to reference to a single submodule while maintaining the correct files/versioning referenced?

        Eg.

        ProjA

        • Lib/base_lib.h (v1.0)

        • Lib/file_only_in_this_commit

        ProjB

        • Lib/base_lib.h (v1.0)

        ProjC

        • Lib/base_lib.h (v1.1)

        Thanks!

        解决方案

        You can use git worktree (available since git 2.5) to create additional worktrees for the Lib submodule, at the locations inside ProjA, ProjB, etc.

        Because git worktree makes it a pain to make several worktrees with the same name (all are called "Lib"), I just created a script, share_submodules to work around the difficulties and create the additional worktree instead of a submodule, set it to the right submodule commit, and do it recursively for all the submodules inside the shared module.

        It should work as well as if the submodule was created by git submodule update --init --recursive, except all copies refer to one module's objects.

        If you're transitioning to it by removing the submodule, there are stray submodule files in your .git and I created find_stray_submodules.py to clean them up.

        这篇关于与单个子模块的多个回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆