A repository uses a submodule. How does a developer get the right version of it?
BeginnerScenarioScale, Submodules, LFS and GitHub Automation
Answer
Situation read → The parent repo pins the submodule to an exact commit.
What I'd do →
- Fresh clone:
git clone --recurse-submodules URL. - Existing clone:
git submodule update --init --recursive. - After pulling the parent, run
git submodule updateto match the pinned commit. - Set
git config submodule.recurse trueto automate it.
Why → The submodule shows as a pointer; nothing updates it unless you run the command.
Interview tip → A "modified: libs/shared (new commits)" status means your checkout differs from the pin.
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?AdvancedSubmodules, subtree or a package manager for sharing code between repos?IntermediateCI cannot clone a private submodule: authentication fails in `actions/checkout`.IntermediateYou must remove a submodule completely.Beginner