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
相关推荐
女生也可以敲代码3 分钟前
AI时代下的50道前端开发面试题:从基础到大模型应用
前端·面试
ZhengEnCi10 分钟前
M5-markconv自定义CSS样式指南 📝
前端·css·python
IT_陈寒28 分钟前
SpringBoot自动配置的坑差点让我加班到天亮
前端·人工智能·后端
xingpanvip28 分钟前
星盘接口开发文档:星相日历接口指南
android·开发语言·前端·css·php·lua
@PHARAOH40 分钟前
WHAT - GitLens supercharged 插件
前端
TT模板1 小时前
苹果cms整合西瓜播放器XGplayer插件支持跳过片头尾
前端·html5
Wect2 小时前
React 性能优化精讲
前端·react.js·性能优化
追风筝的人er2 小时前
SpringBoot+Vue3 企业考勤如何处理法定假期?节假日方案、调休补班与工作日判断链路拆解
前端·vue.js·后端
无敌的黑星星2 小时前
Java8 CompletableFuture 实战指南
linux·前端·python
雁鸣零落3 小时前
如何在 Chrome 中查看其他浏览器的书签?书签空间订阅与侧边栏只读切换指南
前端·chrome·edge浏览器