I'm trying to setup a generic .gitmodules file to be used as a template for a certain static number of submodules new projects always require. Then use the technique shown in Restore git submodules from .gitmodules to init the submodules in one go:
#!/bin/sh
#set -e
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")
        branch_key=$(echo $path_key | sed 's/\.path/.branch/')
        branch=$(git config -f .gitmodules --get "$branch_key")
        if [ ! -d "$path" ]; then
            echo URL - $url, Path - $path, Branch - $branch
            if [ -n "$branch" ]; then
                branch="-b $branch"
            fi
            git submodule add --force $branch $url $path
        fi
    done
However, it seems impossible to specify a tag (as opposed to a branch) in the .gitmodules files:
[submodule "externals/asio"]
    path = externals/asio
    url = https://github.com/chriskohlhoff/asio.git
    branch = asio-1-11-0
which results in:
fatal: Cannot update paths and switch to branch 'asio-1-11-0' at the same time.
Did you intend to checkout 'origin/asio-1-11-0' which can not be resolved as commit?
Unable to checkout submodule 'externals/asio'
It is perfectly possible to do this though:
cd externals/asio
git co asio-1-11-0
Any ideas on how to specify a specific tag ?
No answers on Stackoverflow I have found, even suggested duplicates, show if it is possible to specify a tag in .gitmodules. Also, the questions I've found relate to using git submodule, not using a .gitmodules file to initialize a repo from scratch.
 
     
    