克隆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
相关推荐
云樱梦海13 小时前
OpenClaw官方:OpenClaw Windows Node 实战(1.5K ★ 开源推荐)
windows·开源·github·openclaw
keyipatience13 小时前
25.Linux静态动态库全解析
linux·运维·服务器
爱睡觉11113 小时前
在 Android 模拟器 Shell 下运行 ncnn 推理的性能排查记录
linux·shell
CoderJia程序员甲13 小时前
GitHub 热榜项目 - 周榜(2026-06-06)
ai·大模型·llm·github
落羽的落羽14 小时前
【项目】JsonRpc框架——开发实现1(细节功能、字段定义、抽象层、具象层)
linux·服务器·网络·c++·人工智能·算法·机器学习
Harvy_没救了14 小时前
【github爆款】Headroom:AI代理的智能上下文压缩层 —— 深度解析与洞察
人工智能·github
shixuzhimeng14 小时前
FTP服务器项目
linux·网络·ftp
Chris-zz14 小时前
Linux:线程概念与控制
linux·运维
剑神一笑14 小时前
Linux chown 命令详解:从 inode 到实战
linux·运维·服务器
MIXLLRED14 小时前
随笔——在 Ubuntu 22.04 中查看 Markdown (.md) 文件
linux·运维·ubuntu·markdown