You could use the same mechanism as git submodule init
uses itself, namely, look at .gitmodules
. This files enumerates each submodule path and the URL it refers to.
For example, from root of repository, cat .gitmodules
will print contents to the screen (assuming you have cat
).
Because .gitmodule files have the Git configuration format, you can use git config to parse those files:
git config --file .gitmodules --name-only --get-regexp path
Would show you all submodule entries, and with
git config --file .gitmodules --get-regexp path | awk '{ print $2 }'
you would only get the submodule path itself.