Removing and Deinitializing Submodules
Learn the correct, complete procedure for removing a Git submodule from a repository, including deinitialization, cleanup of .gitmodules, and avoiding leftover state.
When You Need to Remove a Submodule
Submodules are added to pull in external code, but requirements change. You may need to remove one when the dependency is replaced, vendored directly, or simply no longer needed.
Removal is more involved than deleting a folder: a submodule lives in several places at once, and missing one leaves your repo in a broken state.
Where a Submodule Lives
A submodule has three footprints:
.gitmodules— the declarative config.git/config— your local active config.git/modules/<path>— the cached submodule git data
Plus the working tree folder itself. Clean removal touches all of these.
All lessons in this course
- Introduction to Git Submodules
- Adding and Cloning Submodules
- Updating and Synchronizing Submodules
- Removing and Deinitializing Submodules