克隆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
相关推荐
RisunJan33 分钟前
Linux命令-ifconfig命令(配置和显示网络接口的信息)
linux·运维·服务器
LaoWaiHang41 分钟前
Linux基础知识04:pwd命令与cd命令
linux
lbb 小魔仙1 小时前
【Linux】100 天 Linux 入门:从命令行到 Shell 脚本,告别“光标恐惧”
linux·运维·服务器
小张成长计划..2 小时前
【Linux】1:基本指令
linux
OliverH-yishuihan2 小时前
在win10上借助WSL用VS2019开发跨平台项目实例
linux·c++·windows
夜流冰2 小时前
Git - github-git-cheat-sheet
git·github
早川9192 小时前
Linux系统
linux·运维·服务器
阿里嘎多学长2 小时前
2025-12-30 GitHub 热点项目精选
开发语言·程序员·github·代码托管
郝学胜-神的一滴2 小时前
Linux进程与线程控制原语对比:双刃出鞘,各显锋芒
linux·服务器·开发语言·数据结构·c++·程序人生
山上三树3 小时前
进程状态详解
linux·运维·服务器