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)

相关推荐
码流怪侠22 分钟前
GitHub 2026年7月热门项目全景盘点:Agent Skills 生态炸裂,开源世界正在重写规则
程序员·github·agent
我叫黑大帅34 分钟前
git 的 NFD 与 NFC 有什么区别?为什么我有个文件在 NFC 中间不会被当成改动,在 NFD 中就会当成改动
git·面试·github
呆萌很4 小时前
Git push 408 超时、远程断开解决办法
git
Lesile4 小时前
Hands-on Git experience
git
Co_Hui5 小时前
Git 基本使用
git
cooldream20096 小时前
AI 时代,Git 应该怎么学
人工智能·git
DogDaoDao6 小时前
【GitHub】WorldMonitor:一个工程极致主义的实时全球情报仪表盘深度解析
python·程序员·架构·github·go语言·worldmonitor·实时全球情报
其实防守也摸鱼6 小时前
GitHub开源项目破圈方法论:从技术自嗨到生态共赢
服务器·数据库·学习·开源·github·命令行·linux系统
析数塔7 小时前
SleeperGem 技术拆解:恶意 gem 是怎么躲过 CI/CD 扫描的
安全·ci/cd·github
柒和远方7 小时前
V053: 从 Git 回退到 AI 工程治理:Vibe Coding 的 Harness 工作流与质量阀门
git·vibecoding