克隆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
相关推荐
黑猫学长呀1 小时前
存储宝典第2篇:盲封TT wafer是什么意思?
linux·嵌入式硬件·项目·芯片·ufs·晶圆·产测
Strugglingler1 小时前
【Linux 用户态操作 UART】
linux·uart
代码熬夜敲Q1 小时前
ENSP 网络工程实验
linux·运维·服务器
啵啵肠1 小时前
给 AI Agent 一把求职 CLI:推荐一个面向 BOSS 直聘工作流的开源项目 boss-agent-cli
人工智能·github
csdn_life182 小时前
OpenClaw v2026.5.12+ 高级密钥管理:使用SecretRef实现真正的隐蔽存储
linux·openclaw
Terrence Shen2 小时前
Claude Code Harness 源码学习讲义
linux·学习·ubuntu
谷哥的小弟2 小时前
(最新版)Git&GitHub实操图文详解教程(03)—Git工作原理
git·github·版本控制·工作原理·git工作原理
赵药师2 小时前
dpkg: warning: files list file for package ‘libselinux1:amd64‘ missing;
linux·运维·服务器
STDD2 小时前
Samba 文件共享:Linux 服务器与 Windows/Mac 共享文件夹
linux·服务器·windows
liudanzhengxi2 小时前
CRM系统技术文章
linux·服务器·网络·人工智能·新人首发