程序员的资源宝库

网站首页 > gitee 正文

git上传大小超过100M文件(gitee) git上传大文件报错

sanyeah 2024-03-29 14:29:33 gitee 5 ℃ 0 评论

文章目录

    安装LFS
    开启LFS功能
    选择文件类型
    配置远程仓库
    上传大文件
    报LFS错

今天上传项目文件到gitee上面,出现错误

  1. remote: error: File: f422c55c723a183a1944cbec840c0171042c8251 211.94 MB, exceeds 100.00 MB.

意思是单个文件超过100M导致上传失败。搜索到这篇文章关于gitee无法上传大于100M文件的解决方法,自己尝试后成功绕过了gitee对个人社区版的限制。

首先我要说的是网上之前说修改的方法已经不行了,应该是git把这个给修复了。

  1. git config http.postBuffer 524288000

所以目前只能用git lfs工具。
安装LFS

Ubuntu:

  1. curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
  2.  
  3. # 安装 git-lfs到本机
  4. sudo apt install git-lfs

如果提示curl命令没有的,自己再去下载,可能会碰到库没有的情况,百度有解决的方法,我这里放一个链接:curl : Depends: libcurl3-gnutls

Windows:

进入git-lfs官网下载安装包,双击安装程序按提示安装即可。
开启LFS功能

  1. $ cd xxx #'xxx'是你本地仓库目录
  2. # 只需执行一次即可开启lfs功能
  3. $ git lfs install

选择文件类型

设置LFS要管理的文件类型

  1. #因为我是pth模型文件过大,所以我的命令是*.pth,此处需要根据自己情况设定类型
  2. $ git lfs track "*.pth"

配置远程仓库

执行完上面的命令后,会生成一个.gitattributes文件,要将其上传到远程gitee仓库。这里我把.gitattributes和大文件分开上传。

  1. $ git add .gitattributes
  2. $ git commit -m '提交 .gitattributes 文件'
  3. $ git push origin master(如果提交不了,后面可以加一个-f)

上传大文件

  1. $ git add ./Models #我的大文件全在Models文件夹下,根据自己情况更改
  2. $ git commit -m "upload Models"
  3. $ git push origin master -f

报LFS错

在执行上面的最后一步上传命令的时候可能会报两个错误:

  1. WARNING: Authentication error: Authentication required: LFS only supported repository in paid enterprise.
  2. batch response: LFS only supported repository in paid enterprise.

第一个错误可以执行以下命令:

  1. git config lfs.https://gitee.com/{your_gitee}/{your_repo}.git/info/lfs.locksverify false

注: 命令中的{your_gitee}/{your_repo}是你的远程仓库地址,根据自己情况替换。

第二个错误可以尝试删除./git/hooks/pre-push文件

最后重新push一下即可。
 
 

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表