克隆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 小时前
2026年09月28日 | 呱呱AI日报】GitHub 发布 Copilot WSL 教程,介绍在 Ubuntu 中运行编程 Agent
人工智能·github·copilot
顺顺 尼8 小时前
linux 进程信号(上)
linux·c++·算法
niuTaylor9 小时前
飞腾 FT-2000/4 Ubuntu 内存卡 / NVMe SSD 系统制作完整指南
linux·服务器·人工智能·驱动开发·单片机
阿里嘎多学长10 小时前
2026-09-28 GitHub 热点项目精选
开发语言·程序员·github·代码托管
傲世仙尊10 小时前
信号量环形队列与线程池起步-把临界资源拆成很多份
linux
Huangjin007_10 小时前
【Linux 系统篇(二十五)】文件(二) 系统文件I/O详解
linux·运维·服务器
程序员清风10 小时前
vLLM 实战:用 OpenAI 兼容接口部署本地大模型推理服务
开源·github·vllm
ShineWinsu11 小时前
对于ProtoBuffer:ProtoBuffer的介绍以及安装
linux·网络·google·协议·序列化·反序列化·protobuffer
FlightYe11 小时前
视界原理之2D视频(二):视频文件里有什么
android·linux·网络·c++·ffmpeg·音视频·aac
GeW13 小时前
从代码到共识:技术突围如何映照大国相处之道
linux