Interview Prep/Git & GitHub/Scale, Submodules, LFS and GitHub Automation

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 →

  1. Prefer a package manager (npm, PyPI, Maven, Go modules) for libraries with versioned releases.
  2. Use submodules when you need an exact commit of a non-packaged repo, and the team accepts the extra commands.
  3. Use git subtree when you want the code inside the repo with plain clone behaviour.
  4. 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.

All Git & GitHub questions Roadmap: Git & GitHub

More on Scale, Submodules, LFS and GitHub Automation