克隆clone github上某个项目的子目录

有时会遇到只需要克隆github某个项目的子目录,此时可以使用以下方法实现:

需求示例:

现需要克隆:https://github.com/SingleZombie/DL-Demos项目中的ddim项目

注:ddim项目的地址为:https://github.com/SingleZombie/DL-Demos/tree/master/dldemos/ddim

Step1: git clone --filter=blob:none --no-checkout https://github.com/SingleZombie/DL-Demos
Step2: cd DL-Demos, 即表示进行到该目录
Step3: git sparse-checkout init --cone
Step4: git sparse-checkout set dldemos/ddim, 其中dldemos/ddim表示https://github.com/SingleZombie/DL-Demos这个目录下的相对路径
Step5: git checkout master, 其中master表示分支,可以在github项目中查看,如下图所示:

详细的代码步骤如下:

复制代码
git clone --filter=blob:none --no-checkout https://github.com/SingleZombie/DL-Demos
cd DL-Demos
git sparse-checkout init --cone
git sparse-checkout set dldemos/ddim
git checkout master
相关推荐
xuhe211 小时前
Mihon/Tachiyomi漫画插件分析(侧重目前插件现状分析和英文插件推荐)
github·tachiyomi
小锋学长生活大爆炸11 小时前
【教程】PicoClaw:在嵌入式设备上部署OpenClaw
docker·github·教程·工具·openclaw·picoclaw
secondyoung12 小时前
Git使用:Git使用问题及解决方法总结
windows·经验分享·git·vscode·gitee·github·gitcode
Hello.Reader12 小时前
从 0 到 1 理解硬盘数据恢复工具原理与工程实现
linux·运维·服务器·网络·数据库
『往事』&白驹过隙;13 小时前
C/C++中的格式化输出与输入snprintf&sscanf
linux·c语言·c++·笔记·学习·iot·系统调用
Je1lyfish13 小时前
CMU15-445 (2026 Spring) Project#1 - Buffer Pool Manager
linux·数据库·c++·后端·链表·课程设计·数据库架构
好好学习天天向上~~14 小时前
12_Linux学习总结_进程地址空间(虚拟地址)
linux·学习
BugShare14 小时前
飞牛NAS笔记本盒盖不休眠
linux
红球yyds14 小时前
haproxy介绍及部署
linux·运维·云原生
daad77716 小时前
schedule_fair
linux