Git submodules are essentially nested git repositories where the parent repository references the child repository **as a pointer to a specific commit of the child repository **
Updating a Submodule
git submodule update --remote
This does the following
- Git goes to the submodule directory
- Fetches the latest change from its remote
- This happens on the branch specified (usually in
.gitmodules
)
- This happens on the branch specified (usually in
- Checks out the latest commit at the remote
- Even if you’ve just committed and pushed in your submodule, this tells the parent directory to update the commit that it’s referencing for the child repository
- This update needs to staged, committed and pushed like any other file change in git
You don’t need to run this to build/run locally. This is because running locally just uses whichever files are present without regard to git’s commit pointers. That being said, You would need to do this before deploying because this will essentially clone the repositories and it needs to know which commit to clone.