GitHub 上传超过 100M 文件方法

GitHub 上传超过 100M 文件方法

报错信息

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

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

  1. 都添加到暂存区后,就要先上传到本地仓库
git commit -m "big file"
  1. 上面都做完了就直接 push 到远程仓库就行了
git push -u origin master

在这里插入图片描述

相关推荐

  1. Spring Boot优雅实现超大文件 - 通用方案

    2024-01-12 16:02:01       14 阅读
  2. SpringBoot 优雅实现超大文件,通用方案

    2024-01-12 16:02:01       14 阅读
  3. 【SpringBoot】优雅实现超大文件

    2024-01-12 16:02:01       18 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-12 16:02:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-12 16:02:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-12 16:02:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-12 16:02:01       18 阅读

热门阅读

  1. go语言的http post推送

    2024-01-12 16:02:01       34 阅读
  2. LNMP平台对接redis服务

    2024-01-12 16:02:01       25 阅读
  3. 力扣(leetcode)第541题反转字符串II(Python)

    2024-01-12 16:02:01       35 阅读
  4. [BUG] docker: unknown server OS: .

    2024-01-12 16:02:01       31 阅读
  5. 力扣labuladong一刷day59天动态规划

    2024-01-12 16:02:01       25 阅读
  6. SpringSecurity入门demo(四)授权

    2024-01-12 16:02:01       37 阅读
  7. AttributeError: ‘str‘ object has no attribute ‘spilt‘

    2024-01-12 16:02:01       26 阅读