Clone repository with submodule
1
| git clone --recursive <repo_url>
|
Clone submodules after repository cloned
1 2
| git submodule init git submodule update --recursive
|
Add submodule
1
| git submodule add <submodule_clone_url> <submodule_folder>
|
Remove submodule
Step1 - Remove submodule folder
1 2
| git rm --cached /path/to/submodule rm -rf /path/to/submodule
|
Step2 - Remove submodule config in .gitmodules
1 2 3 4 5 6
| -[submodule "themes/next"] - path = themes/next - url = https://github.com/Asing1001/hexo-theme-next.git [submodule "themes/next-reloaded"] path = themes/next-reloaded url = https://github.com/Asing1001/hexo-next.git
|
Update submodule to latest commit
Step1 - Checkout the target version of the submodule
1 2 3 4
| cd projB/projA
git pull origin master
|
Step2 - Commit the update
1 2 3 4
| cd .. git add projB/projA git commit -m "submodule projA updated"
|
Reference