While a git sub module could be added with a single line command such as:
git submodule add https://github.com/UrlToRepository.git foldernameofrepository
it can be cumbersome to remove a submodule. There are various steps involved such as given in the next paragraph.
To remove a submodule you need to:
- Delete the relevant section from the
.gitmodules
file. - Stage the
.gitmodules
changesgit add .gitmodules
- Delete the relevant section from
.git/config
. - Run
git rm --cached path_to_submodule
(no trailing slash). - Run
rm -rf .git/modules/path_to_submodule
- Commit
git commit -m "Removed submodule <name>"
- Delete the now untracked submodule files
rm -rf path_to_submodule
To update all submodule within a repository one would do:
git submodule foreach git pull origin master
Taken from Stackoverflow page https://goo.gl/RVfc1q, answered by John Douthat