2021-07-25
|~1 min read
|152 words
Deleting a git submodule is a potentially confusing aspect of working with them. This is because while they can be removed from some branches, it’s possible that other branches will still expect them to be there — which results in “git yelling at you.”
One approach to this problem I found was:
.git/modules
in the main projectAs an example, if we have a .gitmodules
that looks like this:
[submodule "my-submodule"]
path = my-submodule
url = git@github.com:stephencweiss/my-submodule.git
How might we remove it? A condensed view would look like:
git submodule deinit -f my-submodule
rm -rf .git/modules/my-submodule
git rm -f my-submodule
This would need to be updated if the name of the submodule or its path were not the defaults. Git Submodules: Exploring the Add API
Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!