克隆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
相关推荐
mengge.cloud1 分钟前
0909华为云网络类服务实践小白实验教程
linux·运维·服务器·网络·华为云·php
小诗懂技术2 分钟前
从零手写一个 C 语言 HTTP 商品查询服务器:全链路技术实践
linux·服务器·网络
Escalating_xu3 分钟前
【Linux mmap 文件映射】从虚拟地址到页缓存:读写文件、匿名映射与极简 malloc
linux·缓存
Zixhy9 分钟前
Boost 库实现异步高并发服务器
linux·服务器·c++
楠楠子呀10 分钟前
给 GitHub Pages 这类纯静态站加 WhatsApp 入口:三种不引后端的写法
github
阿明611 分钟前
基础编辑工具使用【Linux】
linux·运维·服务器
Tinyundg12 分钟前
关于Termux的基本使用——安卓手机爆改Linux服务器?
linux·运维·服务器·智能手机·个人开发
鱼很腾apoc25 分钟前
【Linux】第15期 讲解IP网络层核心原理与机制
linux·服务器·网络协议·学习·tcp/ip·ip·网络层
zx_7414848128 分钟前
【Linux入门】常用基本命令(一)——帮助、文件目录操作、时间日期与用户组管理
linux·服务器
AutumnWind042040 分钟前
【Shell 知识速查表】
linux