How to delete a git submodule locally?
14:39 03 May 2023

I want to delete a submodule locally without pushing the changes to mainline.

Here is what I have done:

https://gist.github.com/myusuf3/7f645819ded92bda6677

// Remove the submodule entry from .git/config

$ git submodule deinit -f my_submodule

// Remove the submodule directory from the superproject's .git/modules directory

$ rm -rf .git/modules/my_submodule

// Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule

$ git rm -f my_submodule

Now here is what I have now:

$ git status -s -uno
D  my_submodule

Question> If I commit this change locally and later push all my local changes to main, will these commands cause the submodule(i.e. my_submodule) deleted from mainline?

Thank you

git git-submodules