克隆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
相关推荐
高志小鹏鹏4 小时前
告别“修复 bug”:让别人一眼看懂你的 Commit
git·github·代码规范
hong1616884 小时前
TypeScript类型断言
linux·javascript·typescript
南境十里·墨染春水4 小时前
Linux学习进展 进程管理命令 及文件压缩解压
linux·运维·笔记·学习
李同学Lino4 小时前
别让你的 AI 太安逸!我给代码 Agent 装上了“大厂 PUA”插件,产出直接翻倍(附保姆级教程)
github
航Hang*4 小时前
第2章:进阶Linux系统——第4节:配置与管理NFS服务器
linux·运维·服务器·笔记·学习·vmware
橘子编程4 小时前
操作系统原理:从入门到精通全解析
java·linux·开发语言·windows·计算机网络·面试
用户7365436807435 小时前
用 n8n + GitHub API 搭建 AI 开源项目自动监控系统(Docker 部署 + 评分模型 + Lark推送)
github
逛逛GitHub5 小时前
这个 GitHub 项目很有意思啊,解了死磕30 年的前端难题。
github
亚空间仓鼠5 小时前
OpenEuler系统常用服务(三)
linux·运维·服务器·网络
信工 18025 小时前
rk3568-Linux应用程序和驱动程序接口
linux·驱动开发·rk3568