克隆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
相关推荐
bkspiderx8 分钟前
C++符号冲突与内部符号优先策略详解
linux·服务器·c++·符号冲突·内部符号
tz52533 分钟前
Superpowers 游戏开发实战应用场景大纲
linux·运维·服务器
用户112936112193 小时前
npm 都提示成功了,node_modules 为什么还占着 370M?
linux·前端·后端
女神下凡8 小时前
芯易选(133):建荣(AppoTech)_开发指南
linux·arm开发·stm32·单片机·嵌入式硬件
JWIPC9 小时前
MyClaw 3.0 自动化数据采集实战指南
linux·运维·笔记·科技·深度学习·物联网·自动化
Flynt10 小时前
自托管重开实录:照 HN 419 分热帖让 AI 从零搭一遍,15 分钟踩了三个真坑
linux·开源·ai编程
wflynn10 小时前
GitHub 日榜趋势速报 | 2026-11-27
开源·github
一条Go12 小时前
全链路 e2e:一次跑出 20 个现象,收敛成 5 个根因
后端·github·测试
EmbeddedChen12 小时前
Linux 怎么查看 IP 地址和网络状态?常用网络命令入门
linux·网络·ip·route·ping
一条Go12 小时前
开源新生代雷达 · 第 24 期
github