克隆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
相关推荐
A ?Charis1 小时前
k8s-对接NFS存储
linux·服务器·kubernetes
电棍2334 小时前
GITHUB的若干操作
github
DC_BLOG5 小时前
Linux-GlusterFS进阶配置
linux·运维·服务器
我们的五年5 小时前
MAC地址是如何在局域网中工作的?
linux
浮华落定7 小时前
Centos开机自启动
linux·运维·centos
去看日出7 小时前
CentOS 7 企业级Redis 7部署指南
linux·redis·centos
End9288 小时前
如何安装虚拟机cenos7系统
大数据·linux·运维
果汁分你一半l9 小时前
c++标准io与线程,互斥锁
linux·开发语言·c++·算法·vim
AI云极9 小时前
PyCharm 集成 DeepSeek:本地运行 or API 直连?打造你的 AI 编程神器!
github
WineMonk9 小时前
CentOS查看IP地址
linux·centos