如何用 GitHub 下载单一目录 / 子目录

https://github.com/Timiyang-ai/REACCEPT 为例,只下载其中的 update 目录

完整步骤

  1. 确保已经克隆了仓库并进入仓库目录

    如果你还没有克隆仓库,可以按照以下命令操作:

    bash 复制代码
    git clone --filter=blob:none --no-checkout https://github.com/Timiyang-ai/REACCEPT.git
    cd REACCEPT
  2. 启用稀疏签出(如果没有启用的话)

    配置 Git 使用稀疏签出:

    bash 复制代码
    git config core.sparseCheckout true
  3. 清空 .git/info/sparse-checkout 文件

    清空之前的内容(如果已经有内容):

    bash 复制代码
    > .git/info/sparse-checkout
  4. 指定只下载 update 目录

    update 目录的路径添加到 .git/info/sparse-checkout 文件中:

    bash 复制代码
    echo "update/" >> .git/info/sparse-checkout
  5. 拉取 update 目录的内容

    通过 git checkout 下载 update 目录的内容:

    bash 复制代码
    git checkout main

结果:

这样,你的本地仓库就只会下载 update 目录中的内容,而不会下载整个仓库的其他文件。同理可以用于下载子目录。

相关推荐
一定要AK4 小时前
Spring 入门核心笔记
java·笔记·spring
研究点啥好呢4 小时前
Github热门项目推荐 | 创建你的像素风格!
c++·python·node.js·github·开源软件
_李小白4 小时前
【OSG学习笔记】Day 38: TextureVisitor(纹理访问器)
android·笔记·学习
无限进步_5 小时前
【C++】电话号码的字母组合:从有限处理到通用解法
开发语言·c++·ide·windows·git·github·visual studio
MicrosoftReactor5 小时前
技术速递|使用 Copilot SDK 构建 AI 驱动的 GitHub Issue 分类系统
人工智能·github·copilot
AI成长日志5 小时前
【GitHub开源项目专栏】AI推理优化框架深度解析(上):vLLM架构设计与核心实现
人工智能·开源·github
CV-deeplearning6 小时前
【开源】字节跳动开源 DeerFlow 2.0:一站式 SuperAgent 开发框架,GitHub 星标 5.9 万!
开源·github·deerflow·deerflow 2.0·superagent
_李小白6 小时前
【OSG学习笔记】Day 37: NodeVisitor(顶点访问器)
笔记·学习
Freak嵌入式7 小时前
MicroPython LVGL基础知识和概念:显示与多屏管理
开发语言·python·github·php·gui·lvgl·micropython
SccTsAxR7 小时前
算法基石:手撕离散化、递归与分治
c++·经验分享·笔记·算法