GitHub 上传超过 100M 文件方法

GitHub 上传超过 100M 文件方法

报错信息

bash 复制代码
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.        
remote: error: Trace: a703cdcc9fade51f2a131142249cb422        
remote: error: See http://git.io/iEPt8g for more information.        
remote: error: File ARCore/Data/resources.assets.resS is 130.82 MB; this exceeds GitHub's file size limit of 100.00 MB        
remote: error: File ARCore/Libraries/libiPhone-lib.a is 463.62 MB; this exceeds GitHub's file size limit of 100.00 MB        
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/***.git'

报错原因

GitHub 无论是网页上传还是 git 上传的文件大小都不能大于 100MB,但是 GitHub 提供了上传大文件的解决办法:https://git-lfs.com/

解决办法

我也尝试了网上的很多种方法,但一定要注意命令的执行顺序,不然依旧会提交失败。

  1. 如果没有初始化仓库的话,需要先初始化仓库
bash 复制代码
git init
  1. 初始化完仓库后,要与远程仓库进行连接
bash 复制代码
git remote add origin 仓库地址
  1. 上面两步完成后,下面的就是正式上传大文件的步骤了,首先要安装 lfs
bash 复制代码
git lfs install
  1. 安装完 lfs 后,需要使用 lfs 追踪你要上传的大文件(后缀名)
bash 复制代码
git lfs track "*.sql"
  1. 成功执行第 4 步后,会生成一个 .gitattributes 文件,一定要将这个文件一起 addcommite 以及 push
bash 复制代码
git add .gitattributes
  1. 然后再添加你要上传的大文件
bash 复制代码
git add acdc.sql

或者不需要分开添加,直接全部添加也行
git add .

  1. 都添加到暂存区后,就要先上传到本地仓库
bash 复制代码
git commit -m "big file"
  1. 上面都做完了就直接 push 到远程仓库就行了
bash 复制代码
git push -u origin master
相关推荐
OpenTiny社区2 小时前
🎨 看完 GenUI SDK 源码我悟了!
前端·vue.js·github
千寻girling5 小时前
一份不可多得的《微服务》教程
后端·面试·github
霜落长河8 小时前
用Gemini提升React代码调试效率的教程
github
英勇无比的消炎药9 小时前
TinyRobot 源码深度分析:OpenTiny 的 AI 对话组件库
前端·vue.js·github
逛逛GitHub1 天前
慢慢吃掉你的 Claude Code,在终端里养一只黑洞。
github
jump_jump1 天前
为了重玩金庸群侠传,我研究了一下 Ruffle 怎么复活 Flash
游戏·rust·github
LinXunFeng2 天前
Obsidian - 使用 Share Note 分享笔记并自部署
前端·笔记·github
DayDaydream2 天前
7 天涨了 8000+ Star,Agent Reach 想给 AI 装上互联网眼睛
github
天衍四九3 天前
Git从0到实战(四):冲突解决与版本回退 —— 别怕,出错了也能救
github
大刚测试开发实战3 天前
如何内网穿透访问本地私有化部署的TestHub
前端·后端·github