开发者

Can git submodules have a custom root?

开发者 https://www.devze.com 2023-03-28 01:20 出处:网络
I currently have two projects, 开发者_运维技巧a framework and an application. The repository for the framework contains a number of directories that are not useful in the application. I\'d like to be

I currently have two projects, 开发者_运维技巧a framework and an application. The repository for the framework contains a number of directories that are not useful in the application. I'd like to be able to configure git submodule to only copy the directories I want from my framework repository to the root of my application directory.

Here's what my project directories look like:

Framework

  • /
    • red-locomotive/ - the framework i want to use
    • modules/ - a directory with extra modules
    • lib/ - libraries that the engine depends on
    • examples/ - some tests
    • readme.md etc...

Application

  • /
    • red-locomotive/ - from framework
    • modules/ - from framework
    • lib/ - from framework
    • kernel.js etc...

You can see that I want the three directories from the framework repository in the root of my application. can git submodules do this?


Nope. The submodule will clone the entire repository that it points to. Also you cannot delete any folders from a submodule so there is no way to modify it after including it.

Where I work we have found modules to be quite a pain. Every time you redeployment ( depending on your method) you have to go over every submodule and re initial / add it. We tried to use it for our open source additions like tinymce and tcpdf but pitched that method.


You can do it, but every individual shared folder has to be its own separate submodule. Assuming there are no files at the root level that need to be shared.


While you can not add arbitrary directories from the framework repository in the root directly, you could make the framework a submodule and use a sparse checkout to only get those parts that you need in your working tree (probably combined with shallow cloning of the submodule).

0

精彩评论

暂无评论...
验证码 换一张
取 消