克隆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
相关推荐
水饺编程6 分钟前
第2章:Linux 基础,mkdir 命令的简单入门
linux·c语言·汇编
u1301309 分钟前
GitHub 热榜项目:日榜(2026-10-16)
人工智能·github
自变量yjs10 分钟前
Linux --- 线程控制
linux·运维·服务器
miofly12 分钟前
腾讯开源 Hy Memory 2.0 记忆系统,3B 激活参数超越 claude-sonnet-5-5
开源·github
陌上花开缓缓归以24 分钟前
linux 内核4.4 内存分配使用分析
linux·运维·服务器
欢乐的小猪1 小时前
Linux命令 chmod
linux·运维·服务器
Happy_Sharing1 小时前
Windows虚拟机安装ubuntu后,如何在虚拟机Ubuntu系统中访问Windows文件夹
linux·运维·ubuntu
码上有光2 小时前
Linux:信号的认识、信号的产生、信号的保存、信号的处理
android·linux·运维·信号
anew___2 小时前
《从零手写操作系统 (46):设备模型与devtmpfs——硬件资源的文件系统化》
linux·运维·服务器
Escalating_xu2 小时前
【Linux 网络编程】Windows 客户端访问 Linux:用 Winsock 跑通 UDP 回显
linux·网络·windows