Remove (deinit) a Git submodule

A quick reminder of how to remove a Git submodule, because I always forget

Every once in a while, I need to deinit a Git submodule, but I just cannot remember how. To deinit we can use Git's submodule deinit function to remove it from the database, then we remove the relevant directories from Git.

git submodule deinit -f path/to/submodule
rm -rf .git/modules/path/to/submodule
git rm -f path/to/submodule

After those three commands, you're free to commit the deinit. Note that this will not actually remove the submodule locally, you'll need to rm -r to take care of that.

To make things just a bit easier, we can stick those three lines into a script and call it with a Git alias.