克隆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
相关推荐
miofly几秒前
Nous Research微调Qwen3.8-27B,宣称可剥离中国官方立场内容
开源·github
且从容.2 小时前
Ubuntu安装flume
linux·ubuntu·flume
承渊政道2 小时前
Linux网络学习【Reactor反应堆模式】
linux·网络·学习·ubuntu·reactor
且从容.5 小时前
ubuntu安装flink
linux·ubuntu·flink
用户2991422196806 小时前
GitHub 热榜项目:周榜(2026-11-08)
人工智能·开源·github
用户2991422196806 小时前
GitHub 热榜项目:日榜(2026-11-08)
人工智能·开源·github
爱和冰阔落7 小时前
【Linux网络】TCP 服务器如何并发处理多个客户端?从 fork、僵尸进程到双重 fork
linux·运维·服务器·网络
程序员沉梦听雨7 小时前
WSL2的安装与使用
linux·wsl
微小的鱼7 小时前
Linux的渲染与显示系统链路
android·java·linux
lisanmengmeng7 小时前
alertmanger 标签 rules 打上分组标签
linux·运维·服务器