克隆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
相关推荐
jiayong233 分钟前
GitHub 二开并持续同步上游稳定分支详细指南
github
keyipatience20 分钟前
7.Linux1权限-开发工具
linux
逛逛GitHub33 分钟前
暴击设计行业的 Claude Design ,系统提示词在 GitHub 上泄露了。
github
j_xxx404_1 小时前
万字长文爆肝:彻底弄懂Linux文件系统(Ext2),从Inode、Block到Dentry核心机制全解析
linux·运维·服务器
2401_841495642 小时前
Linux C++ TCP 服务端经典的监听骨架
linux·网络·c++·网络编程·ip·tcp·服务端
楼田莉子2 小时前
同步/异步日志系统:日志器管理器模块\全局接口\性能测试
linux·服务器·开发语言·c++·后端·设计模式
奇妙之二进制2 小时前
zmq源码分析之io_thread_t
linux·服务器
cui_ruicheng2 小时前
Linux IO入门(三):手写一个简易的 mystdio 库
linux·运维·服务器
telllong2 小时前
MCP协议实战:30分钟给Claude接上你公司的内部API
linux·运维·服务器
实心儿儿2 小时前
Linux —— 进程概念 - 程序地址空间
linux·运维·算法