当前位置:   article > 正文

git中commit了过大的文件的解决办法_推送失败,以下文件大小超过单文件 200mb 的系统限额:

推送失败,以下文件大小超过单文件 200mb 的系统限额:


前言

用git提交过一个超过100M的文件,后面文件删除了,git rm xxxx也执行了,但后面每次执行 git push gitee master总是提交不上去。


一、错误代码

错误代码如下

$ git push gitee master
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 12 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 102.23 MiB | 2.08 MiB/s, done.
Total 7 (delta 2), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.2]
remote: error: File: 68ff1c5a3bffce4230214f9a9475506a5137b54a 102.94 MB, exceeds 100.00 MB.
remote: Use command below to see the filename:
remote: git rev-list --objects --all | grep 68ff1c5a3bffce4230214f9a9475506a5137b54a
remote: Please remove the file from history and try again. (https://gitee.com/help/articles/4232)
To gitee.com:xxx.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@gitee.com:xxxx.git'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

二、解决办法

1.原因

在网上看到了一个可能的原因。粘贴一下原文“那就是在commit的时候,之前的版本里面已经包含过这些大文件了,虽然后来在新版本里面删除了大文件,但是之前commit的记录还是存在。所以在统一push的时候就呵呵了。搞清楚这一点,那么我们把大文件的几次提交给它取消不就好了吗。”

2.撤销commit

先查看一下最近提交的commit的版本号。

$ git log
commit ae29792bb4b15042d4471e272a872e4a8d438f77 (HEAD -> master)
Author: dgdqqxxx <2521257530@qq.com>
Date:   Mon Feb 21 15:59:08 2022 +0800

    add a idea from pro.bu

commit 22a987ee129e75e7ed834d495ec201115c12e64b
Author: dgdqqxxx <2521257530@qq.com>
Date:   Wed Feb 16 08:56:32 2022 +0800

    remove deepenhancement

commit 18c9fad0103186c4ea0a80e5ac257abc940a1253
Author: dgdqqxxx <2521257530@qq.com>
Date:   Wed Feb 16 08:54:35 2022 +0800

    add deepenhangcementlearning
    
commit 9fc3bcd9d94a576db065ab70f6f099f289a69be5 (gitee/master)
Author: dgdqqxxx <2521257530@qq.com>
Date:   Sun Feb 13 12:37:43 2022 +0800

    add introduction to SSL
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

可以看到commit 18c9fad0103186c4ea0a80e5ac257abc940a1253这个id就是添加大文件的那次add deepenhangcementlearning的commit,退回到它之前的commit 9fc3bcd这个即可

$ git reset 9fc3bcd9
  • 1

3.重新提交

之后再重新提交即可

git add .
git commit -m '注释'
git push gitee master
  • 1
  • 2
  • 3

三、撤销创建仓库后第一次提交的 commit

执行下面一句即可

git update-ref -d HEAD
  • 1

参考

参考网址:https://www.cnblogs.com/makalochen/p/14484820.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/163218
推荐阅读
相关标签
  

闽ICP备14008679号