git上传大文件到远程仓库中

发布于:2025-03-26 ⋅ 阅读:(22) ⋅ 点赞:(0)
git 上传大文件报错

上传大文件文件到远程仓库上面,出现错误(gitee-100M,github-50M)

remote: error: File: f422c55c723a183a1944cbec840c0171042c8251 135 MB, exceeds 100.00 MB.

意思是单个文件超过100M导致上传失败。

安装LFS
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash

# 安装 git-lfs到本机
sudo apt install git-lfs
如果提示curl命令没有的,自己再去下载,可能会碰到库没有的情况,百度有解决的方法。

开启LFS功能
$ cd xxx #'xxx'是你本地仓库目录
# 只需执行一次即可开启lfs功能
$ git lfs install
选择文件类型

设置LFS要管理的文件类型

#因为我是iso文件过大,所以我的命令是*.iso,此处需要根据自己情况设定类型
$ git lfs track "*.iso"
配置远程仓库

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

$ git add .gitattributes
$ git commit -m '提交 .gitattributes 文件'
$ git push origin master(如果提交不了,后面可以加一个-f)
上传大文件
$ git add ./system
$ git commit -m "upload system"
$ git push origin master -f
报LFS错

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

WARNING: Authentication error: Authentication required: LFS only supported repository in paid enterprise.

$ git config lfs.https://gitee.com/{your_gitee}/{your_repo}.git/info/lfs.locksverify false
# 命令中的{your_gitee}/{your_repo}是你的远程仓库地址,根据自己情况替换。
batch response: LFS only supported repository in paid enterprise.

$ 尝试删除./git/hooks/pre-push文件后再执行git psuh