Git - push超过100M大文件到远程仓库

push超过100M大文件到远程仓库

在用sourcetree提交项目文件到github远程仓库时遇到了下面错误:

remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 4bf53b66a28bfba7ec3396a3fc8e274f
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File client/bin/Debug版本_视频点播器1.0/debug/QtGuid4.dll is 160.99 MB; this exceeds GitHub's file size limit of 100.00 MB
To github.com:wensmq/videoPlay.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@github.com:wensmq/videoPlay.git'

解释:

远程:错误:GH001:检测到大文件。您可能想尝试Git大文件存储  —    https://gitlfs.github.com。
远程:错误:跟踪:4bf53b66a28bfba7ec3396a3fc8e274f
remote: error:参见http://git。更多信息请访问io/iEPt8g。
远程:错误:文件客户/ bin /调试版本_视频点播器1.0 /调试/ QtGuid4.dll 160.99 MB;这超过了GitHub文件大小限制100.00 MB
github.com: wengxxx / videoPlay.git
![远程拒绝]主控->主控(预接收钩子拒绝)
错误:未能将一些参考文件推送到“git@github.com:wengxxx/videoPlay.git”

简单的说,github 会在你上传文件大于50M的时候,给予警告 ; 大于100M的时候给出 server reject(拒绝上传)

解决方案:

1.维持单个文件在100M以内,保持原仓库,剔除单个文件大于100M的,个人觉得这种方案不能根本解决这个问题,建议使用第二种方案。

2.突破github限制,支持单个文件超出100M (使用 Git LFS)

这里给了我们一个很好的处理方案: Git LFS 全名为:Git Large File Storage
Git LFS的官方网址在这里: https://git-lfs.github.com/ ,官网上有很详细的说明,现在来简单说下使用方式:先安装 Git LFS 的客户端,然后在将要push的仓库里重新打开一个bash命令行

  • 只需设置1次 LFS :
git lfs install
  • 然后 跟踪一下你要push的大文件的文件或指定文件类型,当然还可以直接编辑.gitattributes文件。(我这里跟踪的 dll 结尾的文件)
git lfs track "*.dll" 
  • 确保跟踪.gitattributes :
 git add .gitattributes

以上已经设置完毕, 其余的工作就是按照正常的 add , commit , push 流程就可以了 :

git add yourLargeFile.pdf
git commit -m "Add Large file"

我是使用 git bash 来对大文件进行跟踪操作后再用sourcetree提交项目,这样就不会报错啦

在这里插入图片描述
参考:
https://blog.csdn.net/tyro_java/article/details/53440666

  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值