克隆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
相关推荐
一叶知秋yyds11 分钟前
Ubuntu 虚拟机安装 OpenClaw 完整流程
linux·运维·ubuntu·openclaw
楠奕2 小时前
CentOS7安装GoldenDB单机搭建及常见报错解决方案
linux·运维·服务器
剑锋所指,所向披靡!3 小时前
Linux常用指令(2)
linux·运维·服务器
不愿透露姓名的大鹏3 小时前
Oracle归档日志爆满急救指南
linux·数据库·oracle·dba
W.W.H.3 小时前
嵌入式常见的面试题1
linux·网络·经验分享·网络协议·tcp/ip
木白CPP3 小时前
DMA-Buffer内核驱动API文档
linux
HXQ_晴天4 小时前
Linux 系统的交互式进程监控工具htop
linux·服务器·网络
song8584 小时前
韦东山开发手册阅读笔记(五)
linux
LIZhang20164 小时前
linux写一个脚本实时保存内存占用情况
linux·运维·服务器
IDC02-阿杰4 小时前
Windows WSL2安装Ubuntu24.04全攻略
linux·windows