克隆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
相关推荐
何朴尧8 分钟前
centos/cuos如何开启软件源
linux·运维·centos
YouEmbedded13 分钟前
解码Linux文件IO之标准IO
linux·文件io·系统io
撬动未来的支点1 小时前
【Linux内核】Linux内核裁剪完全指南:从理论到实战的系统优化
linux
csdn_Hzx1 小时前
Linux添加一个系统服务
linux·运维·服务器
洛克大航海2 小时前
Ubuntu安装Hbase
大数据·linux·数据库·ubuntu·hbase
赖small强2 小时前
Linux内存管理-缓存系统中的Major和Minor详解
linux·缓存·交换缓存机制·major fault·minor fault
重生之我在20年代敲代码2 小时前
【Linux】初始线程
linux·运维·服务器
问道飞鱼2 小时前
【Linux知识】Linux磁盘开机挂载
linux·运维·网络·磁盘·自动挂载
CoderJia程序员甲2 小时前
GitHub 热榜项目 - 日榜(2025-10-14)
ai·开源·大模型·github·ai教程
试试勇气2 小时前
Linux学习笔记(八)--环境变量与进程地址空间
linux·笔记·学习