$ git submodule add --name <NAME> -b <BRANCH> <REPO_URL> </path/in/repo>
$ git submodule init
$ git submodule update --init
# update branch
$ git config -f .gitmodules submodule.<NAME>.branch <NEW_BRANCH>
$ git submodule update --remote
$ git submodule deinit -f .
$ git submodule update --init
$ git log --oneline [--name-only] -- /path/to/submodule
# list all
$ git config --blob HEAD:.gitmodules --get-regexp path |
awk '{print $NF}' |
xargs -I{} bash -c "echo -e \"\\n~~> {}:\"; git log -1 --oneline -- {}"
[!TIP|label:references:]
example:
$ git config --blob HEAD:.gitmodules --get-regexp [url|branch|path]
# or
$ git config --blob HEAD:.gitmodules --get-regexp ^submodule.\(.+\).\(path\|url\|branch\)
$ git config --blob HEAD:.gitmodules --list
# or
$ git show HEAD:.gitmodules | git config --file - --list
$ git submodule foreach --quiet 'echo $name'
# or
$ git submodule foreach --quiet 'echo $name' |
xargs -I{} bash -c "git ls-tree -z -d HEAD -- {}; echo ''"
$ git show HEAD:.gitmodules | git config --file - --get-regexp path
# or
$ git --no-pager config \
--file \$(git rev-parse --show-toplevel)/.gitmodules \
--get-regexp ^submodule.\\(.+\\).path
$ git show HEAD:.gitmodules | git config --file - --get-regexp url
# or
$ git --no-pager config \
--file \$(git rev-parse --show-toplevel)/.gitmodules \
--get-regexp ^submodule.\\(.+\\).url
# or
$ git submodule foreach -q git config remote.origin.url
# or
$ find .git/modules/ -name config -exec grep url {} \;
# or
$ git config --list | grep -E ^submodule.*.url
$ git config --blob HEAD:.gitmodules --get-regexp branch
$ git submodule deinit -f <NAME> ### operational
$ git rm --cached <NAME>
$ rm -rf <submodulePath>
$ rm -rf .git/modules/<NAME>
$ git config -f .gitmodules --remove-section submodule.<NAME> ### or $ rm -rf .gitmodules
$ git config -f .git/config --remove-section submodule.<NAME> ### or $ vim .git/config