克隆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
相关推荐
2401_868534785 小时前
分析RTOS与Linux有什么区别
linux·运维·服务器
玛丽莲茼蒿6 小时前
Linux/Unix学习笔记(四)—— 进程管理
linux·学习·unix
星栈独行6 小时前
我在 Rust 全栈项目里用 JWT 做无状态认证
开发语言·后端·rust·前端框架·开源·github·web
Peace6 小时前
【Nginx】
linux·运维·nginx
2601_955781987 小时前
飞书远程控机:OpenClaw配置全攻略
人工智能·开源·github·飞书·open claw安装·open claw部署
网络与设备以及操作系统学习使用者7 小时前
Linux与Windows核心差异深度解析
linux·运维·网络·windows·学习
筠筠喵呜喵8 小时前
Linux CPU性能优化:D状态和Z状态排查与处理
linux·服务器·性能优化
张小姐的猫10 小时前
【Linux】多线程 —— 线程同步 | 生产者消费者模型 | POSIX 信号量
linux·运维·服务器
程序员柒叔11 小时前
Graphify——理念不错、社区火但有硬伤的工具
人工智能·大模型·github·知识库
Harm灬小海12 小时前
【云计算学习之路】学习Centos7系统-Linux下用户及组管理
linux·运维·服务器·学习·云计算