克隆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
相关推荐
未济4 天前
linux 配置环境变量
linux
傲世仙尊4 天前
目录即文件-Ext文件系统收尾篇
linux·c语言
_艾伦 耶格尔.4 天前
进程间通信
linux
Liuqy-054 天前
Linux IO编程——静态库、动态库
linux
lpfasd1234 天前
2026年第38周GitHub趋势周报
python·科技·github
彧azz4 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
u1301304 天前
GitHub 热榜项目:日榜(2026-09-21)
人工智能·github
-梅4 天前
linux(8) 软硬链接
linux·运维·服务器
AIgorithmGEEK4 天前
[Linux]线程三部曲(上):一个执行流的诞生——从操作系统一路拆到 pthread_create
linux·线程·pid
张洛闻Eren4 天前
k8s云原生【第十课】:水平 Pod 自动扩缩容
运维·数据库·云原生·kubernetes·github