git上传文件到Gitee报错“error: failed to push some refs to https://gitee.com/xxxx”


前言

我要将一个 4.27 GB 的文件上传到 Gitee 上,但是出现了下面这样的报错
error: failed to push some refs to 'https://gitee.com/xxxx/centos.git
因此记录一下解决报错的方法。


一、创建项目仓库

创建一个新的项目仓库,可以参考我之前写的博客Pycharm集成Gitee及使用,我这里新建了一个名字为 Centos 的仓库。

二、创建工作区

1、在本地新建一个名字为 Centos 的文件夹
在这里插入图片描述
2、进入到 Centos 目录,右键选择 Git Bash Here
在这里插入图片描述
3、初始化本地库

git init

在这里插入图片描述

三、配置 LFS

1、 开启 LFS
前面的博客中我有讲过 Git-LFS 的下载及安装,请参考使用 git push 上传超过100MB文件报错 remote: error: this exceeds GitHub‘s file size limit of 100.00 MB

git lfs install

2、将 CentOS-7-x86_64-DVD-1810.iso 文件移动到当前目录下并执行
在这里插入图片描述

git lfs track CentOS-7-x86_64-DVD-1810.iso

3、追踪需要上传的大文件

 git lfs track CentOS-7-x86_64-DVD-1810.iso

4、添加要上传的文件属性,(要先添加文件属性,不然有可能会失败)

git add .gitattributes

5、添加属性文件上传的说明

git commit -m "pre"

6、建立本地和 Gitee 仓库的链接(起个别名)

git remote add origin https://gitee.com/liupeng97/centos.git

7、上传属性文件

git push [email protected]:liupeng97/centos.git master

在这里插入图片描述
报错原因:

没有生成 SSH 公钥 git

解决办法:

参考我之前所写的博客 Github SSH免密登录

配置完 SSH 公钥后再次上传属性文件即可成功
在这里插入图片描述
Gitee 的项目仓库里面也有了上传的属性文件
在这里插入图片描述

四、上传镜像文件

1、添加要上传的 Centos 镜像文件

git add -f CentOS-7-x86_64-DVD-1810.iso

2、添加要上传的 Centos 镜像文件的说明

git commit -m " CentOS-7-x86_64-DVD-1810.iso"

在这里插入图片描述
3、上传 Centos 镜像文件

git push origin master

在这里插入图片描述
报错了,这里的错误信息主要有两个:

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

batch response: 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}是你的远程仓库地址,根据自己情况替换。
以我的为例

git config lfs.https://gitee.com/xxxx/centos.git/info/lfs.locksverify false

②、第二个错误的解决方法:
删除./git/hooks/pre-push文件

rm .git/hooks/pre-push

在这里插入图片描述
再次上传 Centos 镜像文件

git push origin master

在这里插入图片描述

已成功,再到 Gitee 项目仓库里看一下
在这里插入图片描述


我的qq:2442391036,欢迎交流!


猜你喜欢

转载自blog.csdn.net/qq_41839588/article/details/131566369