克隆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
相关推荐
Vect__5 小时前
深刻理解进程、线程、程序
linux
eastyuxiao6 小时前
如何在不同的机器上运行多个OpenClaw实例?
人工智能·git·架构·github·php
末日汐6 小时前
传输层协议UDP
linux·网络·udp
zzzsde9 小时前
【Linux】库的制作和使用(3)ELF&&动态链接
linux·运维·服务器
CQU_JIAKE9 小时前
4.3【A]
linux·运维·服务器
qing222222229 小时前
Linux中修改mysql数据表
linux·运维·mysql
Alvin千里无风9 小时前
在 Ubuntu 上从源码安装 Nanobot:轻量级 AI 助手完整指南
linux·人工智能·ubuntu
AI成长日志9 小时前
【实用工具教程】AI编程助手趋势全景:从Cursor到GitHub Copilot的实战评测
github·copilot·ai编程
杨云龙UP9 小时前
Oracle 中 NOMOUNT、MOUNT、OPEN 怎么理解? 在不同场景下如何操作?_20260402
linux·运维·数据库·oracle
Amctwd9 小时前
【Linux】OpenCode 安装教程
linux·运维·服务器