# Git Submodules ## Add New Submodules ```bash git submodule add -b [] git submodule update --remote ``` ## Remove Submodules ```bash # Delete the relevant section from .gitmodules git add .gitmodules # Delete the relevant section from .git/config git rm --cached path_to_submodule # no trailing slash rm -rf .git/modules/path_to_submodule git commit -m "Removed submodule " rm -rf path_to_submodule ``` ## Submodule Detached HEAD If a submodule ends up with a detached HEAD: ```bash cd git checkout git branch -u refs/remotes/origin/master master ``` Check `.gitmodule` and `.git/config`, or: ```bash cd git checkout cd git config -f .gitmodules submodule..branch ```