克隆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
相关推荐
lwx9148524 小时前
Linux-特殊权限SUID,SGID,SBIT
linux·运维·服务器
皮卡狮5 小时前
Linux权限的概念
linux
炘爚6 小时前
深入解析printf缓冲区与fork进程复制机制
linux·运维·算法
小义_7 小时前
随笔 3(Linux)
linux·运维·服务器·云原生·红帽
cccccc语言我来了7 小时前
Linux(10)进程概念
linux·运维·服务器
伐尘7 小时前
【linux】查看空间(内存、磁盘、文件目录、分区)的几个命令
linux·运维·网络
Deitymoon7 小时前
linux——PV操作
linux
海兰8 小时前
【实战】MCP 服务在 Nacos 中注册状态分析与优化
android·java·github·银行系统·银行ai
原来是猿8 小时前
Linux进程信号详解(二):信号产生
linux·运维·服务器
阿里嘎多学长8 小时前
2026-04-05 GitHub 热点项目精选
开发语言·程序员·github·代码托管