克隆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
相关推荐
handsome_sai2 小时前
《Linux 小白查看系统与软件商店指南》
linux·运维·服务器
Rabitebla2 小时前
【Linux】 文件系统(五):挂载与软硬链接,多个文件系统怎样组成统一目录树
linux·运维·服务器·c++·笔记·学习·算法
皓月盈江3 小时前
云服务器上部署Hexo静态博客
linux·服务器·hexo·个人博客·云服务器·个人网站·静态博客
qeen874 小时前
【Linux】线程的基本认识及与进程的关系、对比
linux·运维
疯华整猫5 小时前
一条 kill -9 杀不掉的进程:AI 时代,程序员为什么必须精通 Linux
linux
赤生云电竞7 小时前
网吧无盘系统上云:PXE 与云桌面混合部署实践 —— 基于iPXE、iSCSI与NVIDIA vGPU的架构选型
架构·github
爱嘿嘿的小黑7 小时前
用 Google Antigravity 踩遍登录和环境坑后,我开源了个 30 秒只读体检脚本 + Agent Skill
人工智能·python·github
爆米花byh8 小时前
在RockyLinux9环境下安装Rust1.100.0环境
linux·rust
逛逛GitHub8 小时前
7 天 Star 增长超 1000 的新 GitHub 项目,这一波质量很高。
github
爆米花byh8 小时前
在RockyLinux9环境下安装Manticore Search32.1.3单机版
linux·服务器·搜索引擎