克隆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
相关推荐
大刚测试开发实战8 分钟前
如何内网穿透访问本地私有化部署的TestHub
前端·后端·github
uhakadotcom19 小时前
在python 的 工程化架构中 ,什么是 薄包装器层?
后端·面试·github
A小辣椒21 小时前
TShark:Wireshark CLI 功能
linux
A小辣椒1 天前
TShark:基础知识
linux
AlfredZhao1 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
Avan_菜菜1 天前
AI 能写代码了,为什么我反而开始要求它先写文档?
前端·github·ai编程
AlfredZhao2 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
逛逛GitHub2 天前
这个爆红的 GitHub 项目让 token 直接省 60–95%。
github
iccb10132 天前
5年,一个程序员是如何把私有化在线客服系统做到第一名的
前端·后端·github
蝎子莱莱爱打怪2 天前
AI Agent 相关知识扫盲:16 个概念+11张图+38个开源项目推荐
人工智能·github·agent