克隆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
相关推荐
爱吃辣椒的小豆豆7 分钟前
Linux-sshd-实战-白名单与跳板机
linux·运维·服务器
气质、小青年!13 分钟前
进程1学习
linux·学习
blueSatchel32 分钟前
framebuffer注册源码解读
linux·嵌入式
2401_8628808241 分钟前
嵌入式Linux系统移植与驱动开发完整指南
linux·c语言·驱动开发
坤坤子吖1 小时前
Linux 线程同步与互斥——互斥锁
linux·服务器·c++·笔记·学习
miofly1 小时前
GitHub 今日推荐|MOSS-Image:靠坐标框精确控制文字排版的图像生成模型
python·开源·github
TDTC_XQ1 小时前
Linux网络编程accept的讲解
linux·服务器·c++
Python自动化直播1 小时前
自动化笔记:素材管理、命名、轮换的几条土办法
linux·运维·数据库
FlightYe2 小时前
音视频修炼之容器与协议(一):MP4和MOV的box剖析
android·linux·c++·ffmpeg·音视频
小弥儿2 小时前
GitHub今日热榜 | 2026-10-19:智能体生态包场的一天
学习·开源·github