克隆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
相关推荐
serve the people2 小时前
Prompts for Chat Models in LangChain
java·linux·langchain
李昊哲小课2 小时前
Ubuntu 24.04 MariaDB 完整安装与配置文档
linux·ubuntu·mariadb
人间打气筒(Ada)3 小时前
zerotier内网穿透部署(rockylinux部署本地服务器)超详细~~~
linux·内网穿透·内网·公网·zerotier·穿透
计算机小手4 小时前
快速搭建一个 GitHub 开源项目导航网站,提供便捷的信息抓取、智能摘要、分类管理功能
经验分享·docker·github·开源软件
Elias不吃糖4 小时前
Git常用指令合集
linux·git
_OP_CHEN4 小时前
Linux网络编程:(七)Vim 编辑器完全指南:从入门到精通的全方位实战教程
linux·运维·服务器·编辑器·vim·linux生态·linux软件
Maple_land4 小时前
第1篇:Linux工具复盘上篇:yum与vim
linux·运维·服务器·c++·centos
shizhan_cloud5 小时前
Linux 硬盘分区管理
linux·运维
蓁蓁啊5 小时前
Ubuntu 虚拟机文件传输到 Windows的一种好玩的办法
linux·运维·windows·单片机·ubuntu
粟悟饭&龟波功6 小时前
【GitHub热门项目】(2025-11-12)
github