克隆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
相关推荐
W.W.H.几秒前
将驱动编译成模块并安装到rootfs
linux·物联网·wifi·rootfs·驱动
ltl几秒前
io_uring 在生产环境翻车实录:内核 bug、资源泄漏和你不知道的限制
linux
ltl3 分钟前
内存分配器擂台:jemalloc vs tcmalloc vs mimalloc vs glibc
linux
ltl4 分钟前
Zero Copy 的肮脏秘密:在什么时候反而更慢
linux
数据知道17 分钟前
宽字节注入、二次注入、堆叠注入:高级 SQLi 专题
linux·运维·安全·网络安全
童槿顏丶2 小时前
GitLab部署到Linux
linux·运维·gitlab
空堂与归5 小时前
Linux 命令实战:AI 开发者必备的终端操作手册
linux
牢姐与蒯6 小时前
Linux基本指令及知识点(二)
linux·运维·服务器
小玮看世界6 小时前
[Python]从“脏”数据到优雅实现:一个IoT滑动窗口最大值问题的测试驱动优化实录
linux·前端·python