克隆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
相关推荐
哇哈哈20211 天前
信号量和信号
linux·c++
不是二师兄的八戒1 天前
Linux服务器挂载OSS存储的完整实践指南
linux·运维·服务器
慢慢开始吧1 天前
Redmi Note 7 Pro (Violet) 爆改满血 Linux 掌上服务器指南
github
一个人旅程~2 天前
如何用命令行把win10/win11设置为长期暂停更新?
linux·windows·经验分享·电脑
2302_799525742 天前
PCI、PCIe 和 NVLink
linux
~远在太平洋~2 天前
Linux 基础命令
linux·服务器·数据库
模型时代2 天前
GitHub Codespaces存在RoguePilot漏洞,可致GitHub令牌泄露
github
Gofarlic_oms12 天前
避免Kisssoft高级分析模块过度采购的科学评估方法
大数据·linux·运维·人工智能·matlab
~远在太平洋~2 天前
Debian系统如何删除多余的kernel
linux·网络·debian
linux kernel2 天前
第十一部分(下):进程通信
linux·服务器