克隆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
相关推荐
三言老师6 小时前
秘诀-如何远程SSN访问家里的八台电脑(frp 实操方案)
linux·运维·ssh
举手7 小时前
Dispatcher模块剖析
linux·c++
allforgood8 小时前
运行容器
linux
wangruofeng9 小时前
20822 star 的开源录屏软件弃 Tauri 换 Electron:表层是换壳,里子是 46 个 Rust 模块
github·音视频开发
Light_It9 小时前
Linux 内核参数 pci-stub.ids=
linux·kernel
RisunJan10 小时前
Linux命令-scriptreplay(终端会话回放)
linux·运维·chrome
spencer_tseng10 小时前
[kylin & linux] install docker
linux·docker·kylin
x²+(y-√³x²)²=111 小时前
Linux打包文件到Windows,文件/文件类型丢失
linux·运维·windows
CAD老兵11 小时前
一行代码集成 DWG/DXF 图纸查看:测量批注,数据不出站
前端·javascript·github
柒号华仔11 小时前
「速通Shell」聚砖成墙,Shell函数封装之道
linux·ssh·bash