克隆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
相关推荐
开压路机2 小时前
进程控制
linux·服务器
香蕉鼠片2 小时前
跨平台开发到底是什么
linux·windows·macos
bukeyiwanshui4 小时前
20260417 DNS实验
linux
代码中介商5 小时前
Linux 帮助手册与用户管理完全指南
linux·运维·服务器
金融Tech趋势派5 小时前
OpenClaw火了,AI Agent下一步走向哪里?
人工智能·github·企业微信·openclaw·企微管家claw
weixin_449173657 小时前
Linux -- 项目中查找日志的常用Linux命令
linux·运维·服务器
琉璃榴7 小时前
Visual Studio Code连接远程服务器
服务器·vscode·github
想唱rap8 小时前
C++智能指针
linux·jvm·数据结构·c++·mysql·ubuntu·bash
Strugglingler8 小时前
基于whiptail开发shell导航工具
linux·shell·ui设计·whiptail
艾醒(AiXing-w)8 小时前
Linux系统管理(二十)——Linux root磁盘不足?一站式应急清理方案(亲测可用)
linux·运维·服务器