User Tools

Site Tools


git:git-full-remove-submodules

Back to git main page

If you want to fully remove a submodule, the following things have to done :

  • remove the submodule entry from the .gitmodules file in the root of the main git repo
  • remove the variables associated to the submodule
  • remove the description in ./git/modules folder
  • remove the folder containing the submodule

Assume that the submodule is called submod and that it's path relative to the root of the git repo is external/gits

Open a terminal in the root of the git repo, and edit the .gitmodules file to remove the entry

[submodule "external/gits/submod"]
path = external/gits/submod
url = https://github.com/user/submod.git

Remove git tracking of the submodul folder :

git rm -r external/gits/submod

Remove the submodule from git config (all variables are remove using section) :

git config --remove-section submodule.external/gits/submod

stage and commit the changes in .gitmodules

git add .gitmodules
git commit -m "Remove submodule submod"

Remove the submodules from .git/modules

rm -rf .git/modules/external/gits/submod

Finally, push the changes to the remote repo

git push
git/git-full-remove-submodules.txt · Last modified: 2024/05/28 14:33 by admin