克隆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
相关推荐
无巧不成书02185 分钟前
Rust开发环境完全指南:Windows/Linux双平台配置与实战
linux·windows·rust·gnu·msvc·mingw-w64安装·镜像配置
淘矿人9 分钟前
Claude辅助算法设计与优化
人工智能·python·算法·microsoft·github·bug·pygame
Little At Air14 分钟前
C++stack模拟实现
linux·开发语言·c++·算法
逛逛GitHub19 分钟前
给 10 万 Star 的 Hermes 装个记忆外挂,AI 终于能越用越聪明了。
github
特长腿特长37 分钟前
LVS_DR 模式的原理
linux·运维·网络·云原生·centos·lvs
|华|1 小时前
GFS 分布式文件系统
linux
yyk的萌1 小时前
Claude Code 命令大全
linux·运维·服务器·ai·claude code
Fanfanaas1 小时前
Linux 系统编程 进程篇(五)
linux·服务器·c语言·网络·学习·进程
王莎莎-MinerU1 小时前
MinerU 生态全接入:LangChain、Dify、RAGFlow、LlamaIndex 六大框架完整集成指南(2026)
计算机视觉·chatgpt·langchain·pdf·github·aigc
代码论斤卖1 小时前
OpenHarmony teecd频繁崩溃问题分析
linux·harmonyos