克隆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
相关推荐
暴雨课堂5 分钟前
宝塔和云效webhook配置
github
zahuilg105 分钟前
Mac原生终端SSH一键快捷连接|无需装软件、极简安装、快速上手
macos·ssh·github·终端
帅大大的架构之路6 分钟前
linux上面的一些小知识点
linux·运维·服务器
光电笑映11 分钟前
进程间通信:深入 System V IPC:共享内存、消息队列与信号量
linux·运维·服务器·c++
RisunJan11 分钟前
Linux命令-patch (为开放源代码软件安装补丁程序)
linux·服务器·算法
皆圥忈24 分钟前
_Linux文件系统与磁盘结构深度解析
linux
向日葵.27 分钟前
linux & qnx & git 命令 2
linux·运维·git
丑过三八线27 分钟前
Systemd Cgroup 驱动详解
linux·ubuntu·容器
‎ദ്ദിᵔ.˛.ᵔ₎28 分钟前
linux的vim编辑器
linux
用户17128194737532 分钟前
autoflake:Python 代码里没用的 import,让它自己清掉
github