克隆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
相关推荐
活跃的煤矿打工人21 分钟前
【星海saul随笔】Ubuntu基础知识
linux·运维·ubuntu
fasewer1 小时前
第五章 linux实战-挖矿 二
linux·运维·服务器
楚灵魈1 小时前
[Linux]从零开始的网站搭建教程
linux·运维·服务器
小小不董2 小时前
《Linux从小白到高手》理论篇:深入理解Linux的网络管理
linux·运维·服务器·数据库·php·dba
这可就有点麻烦了2 小时前
强化学习笔记之【TD3算法】
linux·笔记·算法·机器学习
DY009J2 小时前
深度探索Kali Linux的精髓与实践应用
linux·运维·服务器
程序员-珍3 小时前
虚拟机ip突然看不了了
linux·网络·网络协议·tcp/ip·centos
码农小白3 小时前
linux驱动:(22)中断节点和中断函数
linux·运维·服务器
4647的码农历程3 小时前
Linux网络编程 -- 网络基础
linux·运维·网络
C++忠实粉丝5 小时前
Linux环境基础开发工具使用(2)
linux·运维·服务器