How to remove a Git submodule
Overview
It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other.
Background
I frequently need to look up the exact series of commands remove a git submodule. This post is primarily for my convenience, but may be useful to others as well.
Modify
Remove the relevant submodule
section from each of the following files:
|
|
|
|
Commit
- Stage changed
.gitmodules
file - Unstage and remove submodule path from the index (don’t include a trailing slash – that will lead to an error)
- Remove submodule files from index
- Commit the changes
- Remove submodule files
|
|
Summary
Removing a submodule can be a tedious task, but can be accomplished by following the tasks in this post.
((( - Enjoy your lighter repository. - )))
References
| Git Reference / git-submodule
| Pro Git > Git Tools / Submodules
| David Walsh / Remove a Submodule