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)

相关推荐
charlee444 小时前
Git使用经验总结8-Git仓库历史记录清除
git·powershell·敏感信息·仓库重置·历史重写
正经教主5 小时前
【Git】Git05-04:Github分支管理与协作流程
git·github
sean9087 小时前
git filter-repo(优秀的 git repo 历史重写工具) 实战
git·repo·工具
hen3y7 小时前
清理 Git 代码库大文件历史记录
运维·git
CoderJia程序员甲7 小时前
GitHub 热榜项目 - 日榜(2025-11-22)
ai·开源·llm·github·ai教程
小Lu的开源日常8 小时前
踩坑日记:为什么Git 突然 Push 不上去了
git·ssh·github
LZ7工作室8 小时前
MAC编程:在MACOS安装和使用 Git 的方法
网络·git·macos·github·个人开发
T***160711 小时前
Git增强现实案例
git·ar
Arva .12 小时前
git常用
git
久莜12 小时前
【Git】使用教程
git