How to remove a submodule from git so that it is deleted from the file system on pull

135 views Asked by At

I have a submodule named my_submodule, which I would like to delete. I need to make sure that it is removed from other developers' file systems as well, to prevent accidentally using it.

I can't require the other develpers to run any extra commands to clean the directory. The repository is worked on by a few hundred people.

I can successfully remove the submodule, which causes it to be removed from git tracking, and also deletes it locally from my file system. When other developers pull the changes, the submodule directory becomes untracked, but is not deleted.They get this error:

warning: unable to rmdir 'path/to/my_submodule': Directory not empty

I've tried the following strategies, which all resulted in the above error. For each strategy, the repo that I pulled to did not have any local changes.

1.

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

Using git version 2.25.1, on Linux.

0

There are 0 answers