Exclude submodule of a submodule

后端 未结 1 1407
梦毁少年i
梦毁少年i 2021-01-18 07:11

I have git repo where I link some of my dependencies using git submodules inside extern/ dir. Say I have a dependency A as a submodule, located at

相关标签:
1条回答
  • 2021-01-18 07:49

    You can use submodule.<name>.update config variable to set which submodule should be updated as mentioned here How to exclude a specific git submodule from update?.

    If you want to exclude the submodule X in A, then you can use the following command:

    git -c submodule."X".update=none submodule update --init --recursive
    

    Note: This assumes that the submodule X in repo A (which is a submodule of extern) is unique across the whole repo extern (including all its submodules, and their submodules and so on...) If X is not unique, then all submodules named X will be skipped in repo extern.


    You can skip the submodules during the cloning process, using the following command:

    $ git -c submodule."X".update=none clone --recurse-submodules <repository>
    

    If the submodule is located in a directory under the repository, then the relative path with respect to its repository should be included in the submodule name. To avoid any confusion, you can get the submodule name from the .gitmodules file in the repository.

    Consider the following example .gitmodules file,

    [submodule "path/to/submodule_X"]
        path = path/to/submodule_X
        url = https://github.com/<user>/<repo>
    [submodule "Y"]
        path = Y
        url = https://github.com/<user>/<repo>
    

    If you want to skip submodule X, then replace <name> in submodule.<name>.update with this "path/to/submodule_X". The same applies to nested submodules.

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