克隆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
相关推荐
aFakeProgramer25 分钟前
S-CORE Docker 环境
linux
江华森41 分钟前
Linux 运维新手入门课
linux·运维·服务器
载数而行5201 小时前
Linux 9 服务管理(进程的一种)
linux
追梦的小菜1 小时前
linux 下磁盘挂载
linux
izcll1 小时前
ubuntu系统安装软件的方法
linux·运维·ubuntu
lpfasd12312 小时前
2026年第24周科技社区趋势周报
github
暮云星影12 小时前
全志linux开发屏幕适配(一)屏幕参数设置说明
linux·arm开发
swordbob14 小时前
NIO 的 Channel 里有多个 BIO 吗?
linux·网络·nio
Fcy64814 小时前
Linux下 信号的保存与捕捉
linux·中断·信号的捕捉·信号的保存
今夕资源网15 小时前
github开源 网页在线音频转文本工具 node.js+html源码
github·音频转文本·音频转字幕·音频转srt·音频转srt字幕文件·音频转lrc·音频转txt