Git submodule to track remote branch

前端 未结 3 1757
猫巷女王i
猫巷女王i 2020-11-30 10:02

I\'m trying to use git submodules for aggregating 10+ repositories into one structure for easy development.

It is supposed to clone the module and checkout a branch.

3条回答
  •  执笔经年
    2020-11-30 10:32

    In order to get this done, I always use the following command (slightly based on VonCs proposal earlier:

    export top=$(pwd)
    git submodule foreach --recursive 'b=$(git config -f ${top}/.gitmodules submodule.${path}.branch); case "${b}" in "") git checkout ${sha1};; *) git checkout ${b}; git pull origin ${b};; esac'
    

    It checks out all submodules (recursively) at their "right" branch (if set) and otherwise at the head as last committed.

提交回复
热议问题