git上传大文件!git push 报错 ! [remote rejected] main -> main (pre-receive hook declined) error_ failed to push some refs to 'xxx

前言

今天在用git push项目的时候,出现了一个报错,记录一下解决方案,以后报同样的错误可以回来看。

错误信息

下面是git push的详细报错信息:

20866@DESKTOP-7R0VL04 MINGW64 /d/AllProjects/JupyterProjects (main)
$ git push origin main
Enumerating objects: 152, done.
Counting objects: 100% (152/152), done.
Delta compression using up to 8 threads
Compressing objects: 100% (147/147), done.
Writing objects: 100% (152/152), 1.45 GiB | 3.57 MiB/s, done.
Total 152 (delta 19), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (19/19), done.
remote: error: Trace: 33c674f670a5be28e672de71fddd6350a7b7bb12f12e9ee5727cb7193071e41b
remote: error: See https://gh.io/lfs for more information.
remote: error: File Recommender Sysytem/music_data.tsv is 2412.03 MB; this exceeds GitHub's file size limit of 100.0
remote: error: File Recommender Sysytem/track_metadata.db is 711.61 MB; this exceeds GitHub's file size limit of 100
remote: error: File Recommender Sysytem/train_triplets.txt is 2862.61 MB; this exceeds GitHub's file size limit of 1
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To https://github.com/wephiles/jupyterProjects.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/wephiles/jupyterProjects.git'

如图所示:
image

查看报错信息:

错误信息提示我们,出错的原因是因为单个文件大小超出了github的最大文件大小100M;

remote: error: File Recommender Sysytem/music_data.tsv is 2412.03 MB; this exceeds GitHub's file size limit of 100.0

解决方法

根据报错信息的提示,git提示我们去https://git-lfs.github.com查看传输大文件的方法。

remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com

我们打开这个网址,看到下面这样的页面:

image

文件详细介绍了如何传输大文件:
image

  • 首先安装下载并初始化:git lfs install,如果你以前没用过这个扩展,那么你需要使用这个命令;如果你已经用过了,你可以跳过这个步骤;

  • 使用命令 git lfs track "这里面写你的文件名称",如果有多个大文件,把每个文件都是用同样的方法操作就可;
    image

  • 使用命令 git add .gitattributes
    image

  • 接下来就是常用的步骤,将文件push上去即可

    git add "这里写你的文件名称"
    git commit -m "这里写你的提交信息"
    git push origin main

提交完成后就可以愉快地传大文件到github了:

image

我的提交又报错了,根据提示,文件的大小要小于等于2GB,那只能把这个大文件删除了,在上传剩下的文件了。
image

我们删除两个大文件后,成功push!
image

posted @   想你时风起  阅读(948)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示