克隆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
相关推荐
繁华如雪亦如歌几秒前
Linux:进程间通信
linux
芥子沫3 分钟前
Memos捷径(Shortcuts)用法介绍
linux·服务器·windows
会编程的土豆19 分钟前
c语言时间戳从入门到精通
linux·c语言·算法
fygfh.30 分钟前
Linux的系统架构浅析
linux·arm开发·系统架构
无敌海苔咪32 分钟前
【解决方案】CentOS 7 网络显示线缆已拔出
linux·运维·centos
何中应33 分钟前
ubuntu如何安装nvm
linux·运维·ubuntu·node.js
cuijiecheng201837 分钟前
Linux下CPP-DateTime-library库的使用
linux·运维·服务器
繁华如雪亦如歌1 小时前
Linux:临界资源、同步与互斥、锁、信号量
linux
QC班长1 小时前
如何进行接口性能优化?
java·linux·性能优化·重构·系统架构
_OP_CHEN2 小时前
【Linux网络编程】(一)初识计算机网络:从独立主机到协议世界的入门之旅
linux·服务器·网络·网络协议·计算机网络·socket·c/c++