克隆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基础IO万字详解:从文件描述符fd到重定向、FILE缓冲机制及MiniShell升级
linux·运维·笔记·学习·状态模式
怕浪猫15 分钟前
Agent 工程化面试:从开发到部署的 5 个关键问题
面试·架构·github
yunwei3719 分钟前
eBPF 入门开发实践教程一:Hello World,基本框架和开发流程
linux·后端·性能优化
小雪崩22 分钟前
嵌入式学习 day65:Linux驱动进阶——pinctrl 子系统和 platform 驱动框架
linux·学习·驱动
高频因子挖掘机25 分钟前
历史 K 线突然少一天?用交易日历、停牌信息和数据校验逐步排查
后端·github·api
miofly28 分钟前
claude-sonnet-5 降价 90% 并支持推理调节
开源·github
wixzjsh39 分钟前
嵌入式Linux系统启动与内核驱动开发全解
linux·运维·驱动开发
用户746381295048141 分钟前
我测了5个边缘AI平台,最后选了最“寒酸”的那个
github
晴天的雨.9921 小时前
【Linux】基础开发工具---软件包管理器
linux·运维·服务器
miofly1 小时前
GitHub 周榜趋势速报 | 2026-10-11
开源·github