DEV Community

loading...

Checkout git submodules by tag

classx profile image classx ・1 min read

In the git documentation can read that the git submodule doesn't support update the submodule by tag.

This is a simple solution:

# update submodule
git submodule update --init
# set tag for boost submodules
DEFAULT_TAG="boost-1.70.0"
# update
git config -f .gitmodules --get-regexp '^submodule\..*\.url$' |
    while read -r KEY MODULE_PATH; do
        NAME="$(echo "${KEY}" | sed 's/^submodule\.\(.*\)\.url$/\1/')"
        if [[ $NAME =~ "boost" ]]; then
          pushd "${NAME}"
          git checkout -b new_branch_boost $DEFAULT_TAG                   
          popd
        fi
    done
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide