I have a set of Git submodules to be included in multiple projects. I use TortoiseGit and adding them one by one to each new project is not convenient.
For example, in TortoiseSVN, one can simply export svn:externals
to a file and then apply this file to a new project. I'm looking for something like that (I'd prefer to avoid scripting if possible).
What is my best bet in this case?
Basically the TortoiseGit add submodule dialog is just a GUI frontend for git submodule add
which basically is just a wrapper for the file .gitmodules
in the root of the working tree.
I.e., you can consider automating the call of git submodule add
or just write a .gitmodules
by hand (or copy it from another repository) and then the submodules need to be registered (this cannot be done using TortoiseGit ATM):
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
git submodule add $url $path
done
Based on: https://gist.github.com/aroemen/5027030