To clone a repo with all its submodules:
git clone --recursive [git://url]
Add a submodule
git submodule add [git://url] [path/to/submodule]
Load submodules if they weren’t when cloning
git submodule update --init
Update all submodules:
git submodule foreach git pull origin master
Removing a submodule:
- Delete the relevant section from .gitmodules
- Stage the .gitmodules changes with
git 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]
(no trailing slash) - Run
git commit -m "Removed submodule [Name of Module]"
to commit the change - Delete the now untracked submodule files
rm -rf [path/to/submodule]
Load remote branches:
git fetch origin
Kirby meets Git https://getkirby.com/docs/cookbook/setup/git