git submodule update --init --recursive

一直卡在clone解决方法,先用ssh clone下源代码,再进入目录,先初始化

git submodule init

再在当前目录下加入下面的脚本

#!/bin/bash

pull_submodule_recursive()
{
    if [ -f ".gitmodules" ];then
        echo ".gitmodules found"
        # backup
        cp .gitmodules .gitmodules.bak
        while read line
        do
            # substitude the https with ssh
            echo ${line} | sed 's/https:\/\/github.com\//git@github.com:/g' >> .new_gitmodules
        done < .gitmodules
        mv .new_gitmodules .gitmodules
        # pull current submodules
        git submodule init
        git submodule sync
        git submodule update
        # get the directories of current submodules
        local directories=$(cat .gitmodules | grep path | awk '{print $3}')
        for directory in $directories
        do
            if [ -d $directory ];then
                # enter the directory
                pushd ${directory} > /dev/null
                # pull one submodule and its submodules
                pull_submodule_recursive
                # return to the last working directory
                popd > /dev/null
            fi
        done
    else
        echo "current submodule has no submodule, return to last directory..."
    fi
    return 0
}

pull_submodule_recursive

最后再运行这个脚本即可,记得赋予执行权限(+x),有可能还是会出现网络问题

bash a.sh
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐