git submodule update --init --recursive无法拉取解决

用

bash 复制代码
git submodule update --init --recursive

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

bash 复制代码
git submodule init

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

bash 复制代码
#!/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 复制代码
bash a.sh
相关推荐
严肃小白兔11 小时前
TanStack Router 更新构建工具链:Node.js 兼容性、路由分割与前端工程实践
前端·node.js·状态模式
IT_陈寒11 小时前
Vue这个奇葩的响应式问题让我加班到凌晨
前端·人工智能·后端
风骏时光牛马11 小时前
功能可用性自动化测试验证
前端
LucianaiB21 小时前
【元宝搜索开发者征文大赛】AI时代,学得慢就不用学?用元宝搜索打造一个教程保质期,确保每一个教程符合你的现状
前端·人工智能·ai编程
excel21 小时前
JavaScript 对象池:减少高频对象创建与 GC 压力
前端
陈随易1 天前
纯 Go 写的 JS 引擎,跑分超过了 C 语言的 QuickJS
前端·后端·程序员
子兮曰1 天前
Chrome 权限元素实战:144 与 151 的渐进增强写法
前端·javascript·chrome
IT_陈寒1 天前
Redis连接池泄漏那次,我差点把生产环境搞崩了
前端·人工智能·后端
强尼银手1 天前
我花一天做了个格斗游戏原型,判定全对,然后被「美术」劝退了
前端·javascript
石小石Orz1 天前
AI 正在蚕食我们的编码能力
前端·后端·算法