How do I init submodules nested in a subtree?

后端 未结 1 1029
醉话见心
醉话见心 2020-12-19 02:41

Apparently, adding a subtree of a repository that has submodules will break git submodule init. Here is a script which reproduces the problem:

#         


        
相关标签:
1条回答
  • 2020-12-19 03:10

    From what I can tell reading the docs and source code... Git subtree is completely separate from Git submodules and will not actively manage any submodules that may be contained within the subtree project itself.

    As you found out, .gitsubmodules, which is critical to the function of git submodule init, needs to be maintained in the root of the "main" repository (for lack of a better term).

    Upon further consideration, it is clear what the problem is: the subtree mechanism has added subtree's submodule reference to submod to the tree, but the .gitmodules metadata remains in subtree/.gitmodules, not the top-level .gitmodules, which means that git submodule init fails. If we copy the contents of subtree/.gitmodules to .gitmodules, adjusting all the paths accordingly, that solves the problem...

    I strongly recommend not mixing these features.

    0 讨论(0)
提交回复
热议问题