Submodules, subtree or a package manager for sharing code between repos?
IntermediateScenarioScale, Submodules, LFS and GitHub Automation
Answer
Situation read → The choice depends on how often the shared code changes and who edits it.
What I'd do →
- Prefer a package manager (npm, PyPI, Maven, Go modules) for libraries with versioned releases.
- Use submodules when you need an exact commit of a non-packaged repo, and the team accepts the extra commands.
- Use
git subtreewhen you want the code inside the repo with plain clone behaviour. - Choose a monorepo if teams change both sides together constantly.
Why → Packages give semantic versions and caching; submodules give exact pins but poor ergonomics.
Interview tip → Acknowledge that submodules are a common source of onboarding pain.
More on Scale, Submodules, LFS and GitHub Automation
A monorepo has 4 GB of history and developers only touch one service. How do you make their day-to-day faster?IntermediateDesigners commit PSD and video assets, and the repo keeps growing. How do you move them to Git LFS?IntermediateYour GitHub LFS bandwidth quota is exhausted and CI pulls fail. What do you do?AdvancedA repository uses a submodule. How does a developer get the right version of it?BeginnerCI cannot clone a private submodule: authentication fails in `actions/checkout`.IntermediateYou must remove a submodule completely.Beginner