Github 下载指定文件夹(git sparse-checkout)

比如要下载这里的 data_utils

步骤

1、新建空文件夹,并进入新建的空文件夹。

2、git init 初始化

3、git remote add origin 添加远程仓库

4、git config core.sparsecheckout true 允许稀疏检出

5、git sparse-checkout set 设置需要拉取的文件夹(可以同时拉取多个,中间加空格即可)

6、git pull origin main 拉取

添加

在已经进行过稀疏检出的文件夹中,添加其它文件夹。

使用git sparse-checkout add。

结果:

ps:git sparse-checkout 和 git lfs 不兼容

参考资料:

https://www.git-scm.com/docs/git-sparse-checkout(官方文档)

https://blog.csdn.net/shelutai/article/details/123116973

https://zhuanlan.zhihu.com/p/57390306

https://cloud.tencent.com/developer/article/2008489

https://github.com/git-lfs/git-lfs/issues/3803(git lfs issue)

相关推荐
鬼手点金38 分钟前
opencode-性能优化建议
java·人工智能·git·自动化·nanogpt
来自于狂人1 小时前
GitHub 开源趋势日报 | 2026年10月7日用 AI Agent 逆向工程一切
人工智能·开源·github
逛逛GitHub2 小时前
盘点 20 个 9 月份 GitHub 上顶顶顶的开源项目。
github
网络毒刘3 小时前
开源 Aider 工作流实战:Git 提交驱动的 AI 结对,与 Cursor 何时互补
git·ai编程·cursor·aider
miofly3 小时前
Google 发布 EmbeddingGemma 2:7.4 亿参数的多模态嵌入模型
开源·github
wflynn4 小时前
GitHub 今日推荐|lightcraft:纯 Rust 重写的 RAW 照片开发工具
rust·开源·github·lightroom·art·photography
wflynn5 小时前
GitHub 日榜趋势速报 | 2026-10-07
开源·github
孟陬5 小时前
#教程 dw, dm, dy, d18m 是何意?万物可 Badge | 定制漂亮精致小徽章,打造眼前一亮 README
npm·github
爱写代码的倒霉蛋5 小时前
新手如何借助agent改造github项目(保姆级教程)
github·新手友好·改造项目
HRTOS5 小时前
HRTOS 4.0 将长期维护:为什么版本号不再频繁变化
经验分享·git·单片机·51单片机