简体   繁体   English

GIT子模块-空文件夹和提交

[英]GIT Submodules - empty folders and commits

Situation: 情况:

We have a project which consists of many submodules stored in app/modules folder. 我们有一个项目,其中包含存储在app / modules文件夹中的许多子模块。 All submodules are independent and each group of users (developers) should work only with a specific subset of the submodules. 所有子模块都是独立的,每组用户(开发人员)应仅使用子模块的特定子集。 This can be easily achieved by executing git submodule update --remote --merge app/modules/SomeModule for specific submodules only (ie don't init/update all available submodules). 这可以通过git submodule update --remote --merge app/modules/SomeModule特定的子git submodule update --remote --merge app/modules/SomeModule执行git submodule update --remote --merge app/modules/SomeModule来轻松实现(即不要初始化/更新所有可用的子模块)。

Question 1: 问题1:

If some user does not need access to certain submodules, empty submodule folder will still exists. 如果某些用户不需要访问某些子模块,则空的子模块文件夹将仍然存在。 Is it possible to ensure that empty submodule folders don't exist by default and are created on request only (eg after init/update) ? 是否可以确保默认情况下不存在空的子模块文件夹,而是仅应请求创建(例如,在init / update之后)?

Question 2: 问题2:

More general question about submodules - is it really needed to commit submodule changes into the main project? 有关子模块的更一般的问题-是否真的需要将子模块的更改提交到主项目中? I know it is used to store the submodule's commit hash to the main project, because it is not stored in the .gitmodules file. 我知道它用于将子模块的提交哈希存储到主项目,因为它没有存储在.gitmodules文件中。 But our submodules are tracked branches git submodule add -b BranchName ... and developers always pull the latest submodule version using git submodule update --remote --merge , is commiting it to the main project needed ? 但是我们的子模块是被跟踪的分支git submodule add -b BranchName ...并且开发人员总是使用git submodule update --remote --merge来获取最新的子模块版本,是否将其提交到所需的主项目中? The main sense is that the submodules and main project are separated, so there seems to be no reason why the main project should know about submodule version/commit/history. 主要的意义是子模块和主项目是分开的,因此似乎没有理由使主项目应该了解子模块的版本/提交/历史记录。

Tracking the SHA of the submodule is really the whole point of submodules. 跟踪子模块的SHA实际上是整个子模块的重点。 So you can check out a specific version / branch of the parent and get the corresponding versions of the children. 因此,您可以签出父级的特定版本/分支并获取子级的相应版本。
If you don't need this, it would be a lot easier to not use submodules in the first place. 如果您不需要此功能,那么首先不用子模块会容易得多。
Just add all directories you currently have as submodules in the .gitignore and every developer can clone the repositories he needs with normal git clone . 只需将当前拥有的所有目录添加为.gitignore中的子模块,每个开发人员都可以使用常规git clone克隆其所需的存储库。
This would solve both your problems. 这将解决您的两个问题。

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

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