克隆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
相关推荐
idolao8 小时前
CentOS 7 安装 nginx-1.3.15.tar.gz 详细步骤(从源码编译到启动配置)
linux·运维·数据库
yaoxin5211238 小时前
358. Java IO API - 使用 relativize() 创建路径之间的相对关系
java·linux·python
老星*8 小时前
Lucide Icons:开源、轻量、设计师友好的现代图标库
ui·开源·github
亚林瓜子8 小时前
linux账号强制密码过期导致私钥文件登录异常问题——(current) UNIX password:
linux·运维·服务器·ssh·aws·ec2·chage
星霜笔记8 小时前
GitMob — 手机端 GitHub 管理工具
android·kotlin·github·android jetpack
Code_LT8 小时前
【AIGC】Claude Code Rules配置
linux·ubuntu·aigc
LXY_BUAA8 小时前
《嵌入式操作系统》_驱动框架_20260318
linux·运维·服务器
淮北也生橘128 小时前
Linux应用开发:全链路 OTA 升级架构
linux·架构·ota·linux应用开发
小黑要努力8 小时前
json-c安装以及amixer使用
linux·运维·json
JiMoKuangXiangQu9 小时前
Linux:ARM64 启动流程
linux·arm64 boot