克隆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
相关推荐
Είναι η κοπέλα4 分钟前
WSL2 部署 AI 开发环境:内核级 Linux + GPU 直通
linux·运维·人工智能
其实防守也摸鱼7 分钟前
网安自测题:掌握核心知识点的实用练习
linux·运维·服务器·前端·数据库·sql·xss
木白CPP8 分钟前
[QNX] 深入理解 Resource Manager 接口设计
linux·服务器·数据库
AlfredZhao11 分钟前
别再 rm 日志了:Linux 下安全清空日志文件的正确姿势
linux
星恒随风14 分钟前
Linux开发工具详解(二):Git版本控制、GitHub协作与GDB调试实战
linux·笔记·git·学习·github
Mortalbreeze18 分钟前
MySQL 基础篇(五):数据操作基础 —— CRUD
linux·服务器·数据库·mysql
cuijiecheng201829 分钟前
Windows 下使用 GitHub Private Repository 管理私人 Visual Studio/C++ 项目
windows·github·visual studio
怕浪猫7 小时前
GEO 优化到底是什么?AI时代内容创作者必须懂的新技能
算法·面试·github
miofly8 小时前
Aleph Alpha 开源 78B 参数 MoE 模型 Kolibri
开源·github
JackSparrow4149 小时前
和AI一起将全部CSDN博文迁移到个人博客站
人工智能·程序人生·ai·github·cloudflare·astro·静态博客