github上传大文件(超过100M)

今天突发奇想,在idea中一边看pdf,一边看源码。于是将PDF访问源码的doc下,想一起上传到github,发现oops。。。

1. 现象

git push 的时候提示错误

remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: a3bc2ecce64c2fb3f5190fe9e9a9e19df6e770d31375307dea4719e9adc8686e
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File docs/Kafka技术内幕.pdf is 112.38 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/bigData-lab/kafka.git

原因是github不允许上传大于100M的文件


2.解决

2.1 github提供的方法

安装 Git LFS(large file storeage),它是 Github 开发的一个 Git 的扩展,用于实现 Git 对大文件的支持。它将你所标记的大文件保存至另外的仓库,而在主仓库仅保留其轻量级指针。
那么在你检出版本时,根据指针的变化情况下更新对应的大文件.而不是在本地保存所有版本的大文件

在这里插入图片描述

2.2 野路子
  1. 切分大文件,切成单个文件小于100M即可(github要求单个文件大小不能超过100M,如果小于100M大于50M只是警告)
  2. 压缩文件
  3. 压缩+切割,我就是将PDF压缩+切割(压缩和切割PDF都有在线工具,直接使用)

3.解决步骤

3.1 安装git-lfs
  • Windows
  1. 下载安装 windows installer
  2. 运行 windows installer
  3. 在命令行执行 git lfs install

在这里插入图片描述
在这里插入图片描述

  • Linux
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install
  • Mac
  1. 安装HomeBrew /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
  2. brew install git-lfs
  3. git lfs install

3.2 使用
  1. 执行 git lfs install 开启lfs功能
    在这里插入图片描述

  2. 使用 git lfs track 命令进行大文件追踪 例如git lfs track “*.pdf” 追踪所有后缀为pdf的文件(修改仓库路径下的 .gitattributes 文件:)
    在这里插入图片描述

  3. 使用 git lfs track 查看现有的文件追踪模式
    在这里插入图片描述

  4. 之后正常add commit push即可
    在这里插入图片描述

  5. 提交后运行git lfs ls-files 可以显示当前跟踪的文件列表

  6. clone 时 使用’git clone’ 或 git lfs clone均可

备注:
github的LFS指南


4. 中途碰到的问题

4.1 问题
$ git push origin read-code-v0.11.0.3-rc0
Remote "origin" does not support the LFS locking API. Consider disabling it with:
  $ git config lfs.https://github.com/bigData-lab/kafka.git/info/lfs.locksverify false
Post "https://github.com/bigData-lab/kafka.git/info/lfs/locks/verify": dial tcp 192.30.255.113:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

解决

//错误信息中已经提供解决思路。将配置中参数设置为false
>git config lfs.https://github.com/bigData-lab/kafka.git/info/lfs.locksverify false
4.2 问题
batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.

解决
目前 Git LFS的总存储量为1G左右,超过需要付费。具体见 github右上角个人头像-Settings->Billing & plans

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

water___Wang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值