前言
用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:
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.原因
在网上看到了一个可能的原因。粘贴一下原文“那就是在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
可以看到commit 18c9fad0103186c4ea0a80e5ac257abc940a1253这个id就是添加大文件的那次add deepenhangcementlearning的commit,退回到它之前的commit 9fc3bcd这个即可
$ git reset 9fc3bcd9
3.重新提交
之后再重新提交即可
git add .
git commit -m '注释'
git push gitee master
参考
参考网址:https://www.cnblogs.com/makalochen/p/14484820.html
|