克隆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
相关推荐
AquaMriusC12 小时前
Windows11专业版使用虚拟化技术安装Linux(CentOS7)
linux·运维·服务器
枳实-叶12 小时前
【Linux驱动开发】第6天:互斥锁mutex/自旋锁spinlock+驱动全流程+应用测试程序
linux·驱动开发
pengyi87101513 小时前
共享IP全面优缺点解析,适合什么人群使用?
linux·运维·服务器·网络·tcp/ip
Little At Air13 小时前
LinuxOS阻塞队列模型(单生产者单消费者)
linux·数据结构·c++
南境十里·墨染春水13 小时前
linux学习进展 git详解
linux·git·学习
念恒1230613 小时前
基础IO(一切皆文件)
linux·c语言·c++·算法
Irissgwe14 小时前
四、进程控制(进程创建与终止)
linux·c++·进程·系统编程·fork·进程创建·进程终止
宵时待雨14 小时前
linux笔记归纳5:进程控制
linux·运维·笔记
阿福聊编程14 小时前
GitHub Trending · 分类汇总(2026-05-11
github
逛逛GitHub14 小时前
盘点 10 个刚刚开源,但 Star 攀升很快的 GitHub 项目。
github