克隆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
相关推荐
hai31524754314 分钟前
九章空间几何对照直译法:通用芯片 / 定制专用芯片 编译适配规则
linux·汇编·bash
ton_tom30 分钟前
设备驱动程序编程-Linux2.6.10-kdb安装-32位
linux·运维·服务器
dong_junshuai1 小时前
每天一个开源项目#26 Caveman:8.2万星的 AI 口语压缩技能,输出减 75%
github
dddwjzx1 小时前
嵌入式Linux C应用编程入门——进程 ( 二 )
linux·嵌入式
jieyucx2 小时前
【系统安全铁律】解密 Linux 权限三色数字密码:chmod 最小化赋权与生产环境避坑指南
linux·安全·系统安全·权限·chmod·777
wangruofeng3 小时前
68K Star,一个爬虫框架凭什么统一了 HTTP、浏览器和 AI Agent
爬虫·github·ai编程
AOwhisky3 小时前
Linux(CentOS)系统管理入门笔记(第四期)——文件系统(下篇):文件与目录操作实战——cpmvmkdirrmln
linux·运维·笔记·centos·云计算·文件系统
岑梓铭4 小时前
考研408《操作系统》复习笔记,第四章《4.2.2 文件操作、文件共享、文件保护》
linux·考研·操作系统·文件系统·408
Mr.HeBoYan4 小时前
DPDK为什么越来越少使用rte_ring?——从Lock-Free到Run-to-Completion,重新理解现代DPDK架构演进(上)
linux·网络·算法·性能优化·架构·dpdk
AC赳赳老秦5 小时前
采购专员自动化:OpenClaw 自动比价、生成询价单、跟踪供应商报价进度实战指南
开发语言·数据库·人工智能·python·自动化·github·openclaw