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)

相关推荐
dreams_dream32 分钟前
项目想要推送多个平台仓库的方法
gitee·github
赵民勇33 分钟前
Git命令详解
git
AI_Lab0135 分钟前
服务器管理工具要在服务器上装 Agent,安全吗?
服务器·安全·github
七牛云行业应用1 小时前
DeepSeek Harness 插件架构 vs MCP:Cordis 的「Everything is a Plugin」到底解决什么
ai·github·ai编程
u1301302 小时前
GitHub 热榜项目:日榜(2026-10-30)
人工智能·github
AlfredZhao2 小时前
新项目首次提交 GitHub 报错“未配置远端 origin”怎么办
github
miofly2 小时前
GitHub 日榜趋势速报 | 2026-10-31
开源·github
u13013014 小时前
GitHub 热榜项目:日榜(2026-10-29)
人工智能·github
穆梓兰煊15 小时前
Python 千万级向量检索内存优化手册
github
用户8371332007615 小时前
AI总是会忘记细节咋办?我用GitHub实现外部记忆管理
人工智能·github