Submodules versus subtrees versus a monorepo: how do you choose?
AdvancedConceptHooks, submodules, LFS and signing
Answer
Submodules give strict version pinning and separate histories but need extra commands and discipline. Subtree (git subtree) copies the other repo's history into a subdirectory, so cloners need nothing special but sync is manual. Monorepo gives atomic cross-project changes and simple tooling but needs build caching, ownership rules and sparse checkout at scale. Choose by how tightly the code changes together.
git subtree add --prefix=vendor/lib https://github.com/org/lib.git main --squash
More on Hooks, submodules, LFS and signing
What are Git hooks and where do they live?BeginnerHow do you share hooks with a team, given `.git/hooks` is not committed?IntermediateWhat does the `commit-msg` hook receive and what is it good for?IntermediateWhat do `pre-receive` and `update` hooks do and how do they differ?AdvancedWhat is a Git submodule?BeginnerWhy do submodules confuse people and what are the common pitfalls?Intermediate