简体   繁体   中英

GIT Submodules - empty folders and commits

Situation:

We have a project which consists of many submodules stored in app/modules folder. 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).

Question 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) ?

Question 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. 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 ? 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. 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 .
This would solve both your problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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