克隆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
相关推荐
无足鸟ICT3 小时前
【RHCA+】sosreport(收集诊断文档)
linux·运维·服务器
GeW3 小时前
世界目光聚焦中国:底层技术、Linux、数据库的破局逻辑
linux·数据库
星恒随风4 小时前
MySQL 从零入门(十):MVCC、Undo Log 与 Read View 详解——InnoDB 如何实现事务隔离?
linux·数据库·笔记·sql·mysql
laoyeye8315 小时前
手写 vLLM 分页 KV Cache(三):引用计数、写时复制(CoW)与前缀缓存
人工智能·github
瑞雪兆丰年兮6 小时前
Linux零基础快速入门-第二章 Linux基础命令
linux·运维·服务器
一条Go8 小时前
边缘 Agent:为什么是它连出来,而不是平台连进去
后端·架构·github
咋的啥名都用不了呢~8 小时前
Linux项目部署6(安装Elasticsearch)
linux
一条Go8 小时前
开源新生代雷达 · 第 15 期
github
OpenTiny社区9 小时前
我用Vue 100%复制DeepSeek开源的网页App,代码更少,功能还更多!
前端·vue.js·github
无奈笑天下9 小时前
银河麒麟桌面上USB打印机无法打印问题标准处理流程
linux·运维·网络协议