克隆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
相关推荐
比奇堡派星星4 小时前
awk命令
linux·运维·服务器
清水白石0084 小时前
Python 柯里化完全指南:从函数式思想到工程实践
linux·服务器·python
m0_694845574 小时前
netcut 是什么?简单安全的在线剪贴板搭建与使用教程
运维·服务器·安全·开源·云计算·github
宸迪5 小时前
【python】使用uv管理项目包依赖
linux·python·uv
HalvmånEver6 小时前
Linux:基于信号量的环形队列与生产者消费者模型(一)
linux·运维·服务器·信号量
中科三方6 小时前
域名注册后无法解析解决方法:技术故障排查和解决指南
开发语言·github·php
威桑7 小时前
解决 Qt6 程序 在Linux 环境下无法输入中文的问题
linux·c++·qt
j_xxx404_7 小时前
Linux:文件描述符fd
linux·运维·服务器
未既7 小时前
逻辑卷挂载磁盘操作命令
linux·运维·服务器
李斯维8 小时前
安装 Arch Linux 到 VMware Workstation 的完全指南
linux