克隆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
相关推荐
YJlio18 小时前
PsService·下(7.21):Find/SetConfig 与服务的启动/停止/重启/暂停/恢复
linux·运维·服务器
波诺波18 小时前
环境管理器
linux·前端·python
诸葛思颖18 小时前
把本地 Python 项目用 Git 进行版本控制并推送到 GitHub
git·python·github
_OP_CHEN18 小时前
Linux系统编程:(六)深入理解 Linux 软件包管理器——从原理到 yum 实战全攻略
linux·运维·服务器·yum·软件包管理器·linux生态
人工智能训练19 小时前
Ubuntu系统中Docker的常用命令总结
linux·运维·人工智能·ubuntu·docker·ai
KYGALYX1 天前
在Linux中备份msyql数据库和表的详细操作
linux·运维·数据库
余—笙1 天前
Linux(docker)安装搭建CuteHttpFileServer/chfs文件共享服务器
linux·服务器·docker
lang201509281 天前
Linux高效备份:tar与gzip完全指南
linux·运维·服务器
IDOlaoluo1 天前
OceanBase all-in-one 4.2.0.0 安装教程(CentOS 7/EL7 一键部署详细步骤)
linux·centos·oceanbase
catoop1 天前
在 WSL 的 Ubuntu 中安装和配置 SSH 服务
linux·ubuntu·ssh