Git Submodule
Start
June 18, 2022
End
June 18, 2022
Period
1Days
PIC
Last Updated
June 18, 2022
sAdd a submodule
git submodule add <repository-to-submodule> <path/name>
Convert a directory under Git management into a submodule
git mv bar bar.bk
git add -A
git add submodule <repository-to-submodule> bar
Update submodules
git submodule update
Remove a submodule
git submodule deinit -f <submodule-name>
git rm -f <submodule-name>
rm -rf .git/modules/<submodule-name>
When git status shows (modified content), here’s how to handle it:
- Commit changes inside the submodule
- Navigate into the submodule directory
- git add
- git commit
- Push to the submodule’s master branch
- git push origin master
- Check the diff
- git diff
- Commit the updated submodule reference in the parent project
- git add
- git commit