克隆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
相关推荐
赖small强2 小时前
【Linux驱动开发】Linux SDIO 底层原理与实现细节详解
linux·驱动开发·sdio
llxxyy卢4 小时前
通关upload-labs(14-21)加分析源码
linux·运维·服务器
松涛和鸣6 小时前
11.C 语言学习:递归、宏定义、预处理、汉诺塔、Fibonacci 等
linux·c语言·开发语言·学习·算法·排序算法
C-DHEnry8 小时前
Linux 不小心挂载错磁盘导致无法启动系统咋办
linux·运维·服务器·雨云
破烂pan8 小时前
github下载repo中的单独文件
github
SelectDB11 小时前
Doris MCP Server v0.6.0 正式发布
github
hakukun11 小时前
Ubuntu启动时volume报错无法进入系统问题解决
linux·ubuntu
qq_4017004111 小时前
Linux磁盘配置与管理
linux·运维·服务器
hoo34312 小时前
【SolidWorks2025】3D CAD 软件:机械设计安装 + 补丁教程
linux
先知后行。12 小时前
STM32常问问题
linux