克隆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
相关推荐
咋吃都不胖lyh1 小时前
linux环境在vscode链接到一个git仓库,克隆和拉取详细命令行
linux·git·vscode
小小小米粒3 小时前
NAT 模式, 仅主机模式 Host-Only ,桥接模式 Bridge
linux·服务器·网络
解道Jdon7 小时前
VSCode 2026年2月更新:技能市场、CLI、钩子支持
ide·windows·git·svn·eclipse·github·visual studio
沙漏无语7 小时前
(二)TIDB搭建正式集群
linux·数据库·tidb
思麟呀7 小时前
计算机网络初步认识
linux·计算机网络
浩子智控8 小时前
zynq嵌入式开发(2)—基本开发测试实例
linux·嵌入式硬件·硬件架构
闻道且行之8 小时前
Nginx 安装、做成服务及 HTTPS 配置全流程
linux·运维·nginx·https
昵称只能一个月修改一次。。。8 小时前
Linux系统编程:网络编程
linux·服务器·网络
猫猫的小茶馆8 小时前
【Linux 驱动开发】Linux 内核启动过程详解
linux·c语言·arm开发·驱动开发·stm32·单片机·mcu
人工智能训练8 小时前
Qwen3.5 开源全解析:从 0.8B 到 397B,代际升级 + 全场景选型指南
linux·运维·服务器·人工智能·开源·ai编程