克隆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
相关推荐
Lonely 净土5 小时前
Linux 运维文件写入操作
linux·运维·服务器·文件管理
吠品8 小时前
Wine 在 Linux 上运行 Windows 软件完整指南
java·linux·服务器
深念Y10 小时前
从 Windows 迁移到 Linux 开发环境的记录
linux·windows·链接·bun·ram·imdisk
领创工作室10 小时前
GitHub Workflows 全面解析:从核心概念到开源实现
运维·github
知无不研11 小时前
Linux I/O复用之epoll
linux·服务器·epoll·socket编程
fb_1234512 小时前
Linux运维封神|SELinux详解+CentOS7启动原理+Root密码重置+开机故障排查实战
linux·运维·服务器
苏宸啊12 小时前
linux网络编程udp服务器和客户端代码编写(echo版本和字典版本)
linux·网络
~|Bernard|12 小时前
Linux 定时任务(Cron)完整教程
linux·运维·服务器
一条泥憨鱼12 小时前
【从0开始学习计算机网络】| DNS -记录类型详解
计算机网络·http·github·域名·dns·记录
小雪崩13 小时前
嵌入式学习 day25:哈希表及排序与查找
linux·c语言·数据结构·学习·排序算法