admin管理员组文章数量:1648646
今天突发奇想,在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 野路子
- 切分大文件,切成单个文件小于100M即可(github要求单个文件大小不能超过100M,如果小于100M大于50M只是警告)
- 压缩文件
- 压缩+切割,我就是将PDF压缩+切割(压缩和切割PDF都有在线工具,直接使用)
3.解决步骤
3.1 安装git-lfs
- Windows
- 下载安装 windows installer
- 运行 windows installer
- 在命令行执行 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
- 安装HomeBrew /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent/Homebrew/install/master/install)”
- brew install git-lfs
- git lfs install
3.2 使用
-
执行 git lfs install 开启lfs功能
-
使用 git lfs track 命令进行大文件追踪 例如git lfs track “*.pdf” 追踪所有后缀为pdf的文件(修改仓库路径下的 .gitattributes 文件:)
-
使用 git lfs track 查看现有的文件追踪模式
-
之后正常add commit push即可
-
提交后运行git lfs ls-files 可以显示当前跟踪的文件列表
-
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/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
版权声明:本文标题:github上传大文件(超过100M) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1729493330a1202656.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论