克隆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
相关推荐
想做后端的小C9 分钟前
Linux:期末考点
linux·运维·服务器
我可以将你更新哟13 分钟前
【linux】配置 Docker 国内镜像源, centos7安装docker-ce,docker相关命令,永久配置 DNS
linux·运维·docker
代码游侠21 分钟前
复习——网络测试工具
linux·开发语言·网络·笔记·学习·测试工具
知识分享小能手30 分钟前
Ubuntu入门学习教程,从入门到精通,Ubuntu 22.04 系统启动与关闭详解(11)
linux·学习·ubuntu
machunlin~31 分钟前
centos 系统安装相关
linux·运维·docker·centos
hweiyu0033 分钟前
Linux 命令:bzip2
linux·运维·服务器
爱吃生蚝的于勒1 小时前
【Linux】深入理解软硬链接
linux·运维·服务器·c语言·数据结构·c++·算法
-拟墨画扇-1 小时前
Git | 多人协助策略
git·gitee·github·gitcode
djxbbdjedhb1 小时前
Linux应用学习-读取jpg显示在LCD上
linux·学习
Huazzi.1 小时前
使用Scoop安装Git
git·elasticsearch·gitee·ssh·github·scoop