克隆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
相关推荐
一次旅行15 小时前
AI 前沿日报 | 2026年7月3日 星期五
人工智能·github·ai编程
风曦Kisaki18 小时前
#Linux数据库管理Day06:主从同步与MaxScale读写分离
linux·运维·数据库
小楼昨夜又东风12618 小时前
使用python快速拉包
linux
Tipriest_19 小时前
ubuntu创建和更换当前swap大小
linux·运维·ubuntu
青山木20 小时前
快速搭建免费的个人博客网站:Hexo + GitHub Pages + Butterfly 完整指南
git·github
WI8LbH78820 小时前
Ubuntu 部署Harbor
linux·运维·ubuntu
researcher-Jiang21 小时前
高性能计算之MPI:第一次MPI并行程序设计练习
linux·运维·服务器
Wireless_wifi621 小时前
Why Choose IPQ9574 for Your WiFi 7 Solution
linux·人工智能·5g
MYMOTOE61 天前
国内对标腾讯 WorkBuddy 的桌面 AI 智能体软件大全
linux
小c君tt1 天前
linux学习笔记1
linux·笔记·学习