克隆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
相关推荐
阿里嘎多学长几秒前
2026-03-15 GitHub 热点项目精选
开发语言·程序员·github·代码托管
虾..4 分钟前
Linux 自定义协议完成网络版本计算器
linux·运维·网络
色空大师4 分钟前
【Linux ln 命令详解】
linux·运维·服务器·链接·ln
( ⩌ - ⩌ )13 分钟前
wmware中相机打开失败的解决
linux·ubuntu·相机·wmware
wait a minutes15 分钟前
【大模型】本地怎么通过kilo code调用Qwen免费模型
linux·运维·服务器
江畔何人初19 分钟前
Argo CD 的核心架构组件与作用
linux·服务器·云原生·kubernetes
LuL_Vegetable20 分钟前
写一个Linux服务器自动tcpdum抓包脚本
linux·wireshark·bash·tcpdump
草莓熊Lotso29 分钟前
Linux 进程间通信之命名管道(FIFO):跨进程通信的实用方案
android·java·linux·运维·服务器·数据库·c++
淮北49435 分钟前
ubuntu下好用的工具
linux·运维·ubuntu
知无不研40 分钟前
Linux主函数的参数含义
linux·运维·服务器·主函数的参数