In one of our git repo, there was a submodule added at some point. Now, whenever I checkout a state of the git repo, where the submodule was not yet there it does not properly "remove" the submodule. It seems to be in a state, where the submodule is half there, half not.
I also noticed, that the submodule is no longer preset in
git reset --hard
git submodule foreach reset --hard
git clean -d -f
Skipping repository path/to/submodule
git submodule update --init
You need to run
git clean with double
-f arguments. From the documentation (emphasis mine):
If the Git configuration variable clean.requireForce is not set to false, git clean will refuse to delete files or directories unless given -f, -n or -i. Git will refuse to delete directories with .git sub directory or file unless a second -f is given. This affects also git submodules where the storage area of the removed submodule under .git/modules/ is not removed until -f is given twice.
So the correct command is:
git clean -d -f -f