克隆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
相关推荐
用户5268356779012 小时前
存储运维实战:基于 Ceph Event 监听与 Python 适配器的分布式存储健康度物理声光响应架构
github
2401_8275012812 小时前
Linux系统移植
linux·arm开发·单片机
dong_junshuai12 小时前
每天一个开源项目#58 DwarfStar:2万星原生引擎,让DeepSeek V4跑在Mac上
github
2601_9657984713 小时前
Build a Consulting Site in 2026: Nifty Theme Practical Review
java·linux·数据库
加油码13 小时前
共享内存详解:原理、系统调用与高性能进程间通信
linux·c语言·c++
枳实-叶13 小时前
Linux 环境下段错误出现的原因及调试方法
linux·运维·服务器
Dawn-bit14 小时前
Linux文本处理三剑客之sed详解
linux·运维·服务器·云计算·运维开发
dok1214 小时前
Johannes 《Linux内核模块与设备驱动开发:编写Linux驱动程序》 (9)manual_cdev
linux·运维·驱动开发
Cx330❀14 小时前
【Linux网络】深入 HTTP 协议(五):从 Cookie/Session 原理到 C++ 源码实战
linux·运维·服务器·开发语言·网络·c++·http
keyipatience14 小时前
Socket编程3个版本
linux·运维·服务器·开发语言·网络·ubuntu