克隆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
相关推荐
吳所畏惧15 分钟前
Linux环境/麒麟V10SP3下离线安装Redis、修改默认密码并设置Redis开机自启动
linux·运维·服务器·redis·中间件·架构·ssh
yueguangni26 分钟前
sysstat 版本 10.1.5 是 CentOS 7 的默认版本,默认情况下确实不显示 %wait 字段。需要升级到新版sysstat
linux·运维·centos
萧曵 丶2 小时前
Linux 业务场景常用命令详解
linux·运维·服务器
豆是浪个2 小时前
Linux(Centos 7.6)命令详解:ps
linux·windows·centos
Run_Teenage3 小时前
Linux:深刻理解缓冲区
linux
youxiao_904 小时前
kubernetes 概念与安装(一)
linux·运维·服务器
凡梦千华4 小时前
logrotate日志切割
linux·运维·服务器
wdfk_prog4 小时前
[Linux]学习笔记系列 -- [fs][proc]
linux·笔记·学习
拜托啦!狮子4 小时前
安装和使用Homer(linux)
linux·运维·服务器
liulilittle5 小时前
XDP VNP虚拟以太网关(章节:一)
linux·服务器·开发语言·网络·c++·通信·xdp