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
相关推荐
梦曦i21 小时前
@meng-xi/create-uni-app vs unibest:轻量脚手架与重型框架的定位之争
前端·uni-app
平头哥技术团队21 小时前
Day 10 | 工欲善其事:VS Code 配置与项目归档
android·开发语言·前端·javascript·html·交互
乌恩大侠1 天前
GH200 新增 NVMe SSD 分区、格式化与挂载完整流程
运维·服务器·前端
yume_sibai1 天前
Element Plus 数据展示组件完全指南(15个核心组件)
前端·javascript·vue.js
Draw Stars1 天前
Git BASH安装教程
开发语言·git·bash
Akiyama_Mio-Kon1 天前
2026 最新:Dify 本地 Docker 部署完整教程(Windows + Git Bash)
windows·git·docker
qiuhaipeng11 天前
Claude code 升级后上下文长度变短问题
java·前端·数据库
zzz_23681 天前
个人 AI 记忆如何跨工具复用:用 Markdown、索引和 Skill 搭一个可治理的记忆库
前端·人工智能·react.js·前端框架·agent·agent测评
剑之所向1 天前
.NET 官方`System.Threading.Channels`
前端·javascript·数据库
计算机魔术师1 天前
GPT-6 Astra幻觉砍到2%,却被一种老招数轻松绕过
前端