克隆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
相关推荐
逛逛GitHub11 分钟前
Claude 最新模型发布 1 周了,瞧瞧外网惊艳到震撼的玩法。
github
逛逛GitHub13 分钟前
最近逛 GitHub 挑了 8 个刚开源、Star 涨得挺快的项目。
github
dong_junshuai2 小时前
每天一个开源项目#158 AG-UI:让Agent事件流接上前端状态
github
吴长建先生重名了3 小时前
一个任务调度系统崩溃 Bug 从性能压测中暴露的真相
github
dingdingfish4 小时前
TLPI 第52章 读书笔记:POSIX Message Queues
linux·mq·ipc·posix·message·tlpi
wacsii5 小时前
【Linux进程(五)】进程控制全解析:从创建、终止、等待到程序替换
linux·服务器
七夜zippoe5 小时前
Nexent Linux 部署:用 deploy.sh
linux·服务器·docker·部署·ai智能体·nexent
去码头整点薯条986 小时前
NFS服务器
linux·运维·服务器
蜗牛一步步往上爬6 小时前
第一章 初识Linux shell
linux·运维·服务器