Overview
Use submodules when you need to:- Include a library as a subdirectory
- Share code between projects
- Pin external dependencies to specific versions
- Keep separate repositories for components
Commands
Add Submodule
- Clones the repository to
vendor/utils - Records the submodule in
.witmodules - Stages the changes
Initialize Submodules
After cloning a repo with submodules:.witmodules.
Update Submodules
Status
Run Command in Submodules
Configuration File
Submodules are recorded in.witmodules:
Workflow
Adding a Submodule
Cloning a Repo with Submodules
Updating a Submodule
Removing a Submodule
Directory Structure
Use Cases
Shared Libraries
Pinned Dependencies
Multi-repo Project
Best Practices
Troubleshooting
Submodule is empty
Submodule is empty
Run init and update:
Submodule has modifications
Submodule has modifications
Either commit them in the submodule:Or discard:
Can't push submodule changes
Can't push submodule changes
Ensure you have push access to the submodule’s repository, then push from within the submodule: