将本地仓库push到远程仓库的时候报错,文件过大:
remote: Powered by GITEE.COM [GNK-6.1]
remote: error: File: 91074a92c31a1438e8a65c93e1a36d796e85fedd 152.58 MB, exceeds 100.00 MB.
remote: Use command below to see the filename:
remote: git rev-list --objects --all | grep 91074a92c31a1438e8a65c93e1a36d796e85fedd
remote: Please remove the file from history and try again. (https://gitee.com/help/articles/4232)
然后使用指令文件目录:
git rev-list --objects --all | grep 91074a92c31a1438e8a65c93e1a36d796e85fedd
返回结果:
91074a92c31a1438e8a65c93e1a36d796e85fedd xxx/xxx/opencv
使用指令删除文件:
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch xxx/xxx/opencv' --prune-empty --tag-name-filter cat -- --all
删除后再次提交代码结果还是报相同的错误!
原因
上传时候,其实不止是push当前版本,还要push所有历史版本,如果之前某次commit没有上传,那么这个历史版本也要默认push
解决
使用git log查看所有版本
MAC project % git log
commit 6d879f2552b69151a0bd86acfa83c8ffd6038539 (HEAD -> main)
Author: FancooZhang <505658864@qq.com>
Date: Fri Sep 17 11:12:27 2021 +0800
提交一下
commit 3c6943e5823e0f842ede3e6a7468e3442dd1aab8 (origin/main)
Merge: bd5c23c dd3235d
Author: RenShen <ren.shen@qq.com>
Date: Thu Sep 16 08:32:26 2021 +0000
提交一下
因为之前的版本6d879f2552b69151a0bd86acfa83c8ffd6038539 commit后没有push,所以要撤回版本6d879f2552b69151a0bd86acfa83c8ffd6038539,需要reset到版本3c6943e5823e0f842ede3e6a7468e3442dd1aab8,
然后
git reset 3c6943e5823e0f842ede3e6a7468e3442dd1aab8
然后继续 git add -> git commit -> git push 最后成功!
参考:
https://www.cnblogs.com/rixiang/p/12048849.html
https://blog.csdn.net/qq_43915356/article/details/113619750