Zettelkasten
Wonko's collection of notes

Posted on , in Programming, tagged with

Should you use submodules in Git?

When starting a larger project, there is the question of how to partition code and if submodules could help. With git, you can either put all your code in one repository or use submodules.

Benefits of a single repository

Benefits of Submodules

Requirements to use submodules

Using submodules will work well for:

Indicators when not to use submodules

So . . .

It must be mentioned, that the Linux kernel developers created git based on their experience creating the kernel and they do not use submodules. They manage twenty different architectures and hundreds of drivers and modules in one single repository. But then, the kernel is a very different kind of project, compared with whatever you are planning.

If the use of submodules seems to create extra work this can be viewed to some extend as effort that would be needed later, when untangling a component for reuse in a different project. If your pull requests in one repository stall because of other pull requests in other repositories, those two components should probably be developed in the same repository (for a while?).

My recommendation is to start with 1 repository and whenever a component appears as a good submodule candidate, extract it into one.