You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

删除超限文件后仍无法向GitHub推送代码的问题求助

GitHub推送报错:超大文件已删除仍无法提交

问题描述

多次尝试向GitHub仓库推送提交,系统提示存在超大文件,但该文件已从仓库中删除,仍无法完成推送。相关操作命令及输出如下:

allen@ubuntu:~/Projects/Mapper/mapper_QT$ git push
Enumerating objects: 290, done.
Counting objects: 100% (239/239), done.
Delta compression using up to 8 threads
Compressing objects: 100% (178/178), done.
Writing objects: 100% (182/182), 105.54 MiB | 1.13 MiB/s, done.
Total 182 (delta 125), reused 0 (delta 0)
remote: Resolving deltas: 100% (125/125), completed with 51 local objects.
remote: error: Trace: 0730b46f05dd95225e52b3f579b71ad134147f2b6710c5e580ba973961876a9f
remote: error: See https://gh.io/lfs for more information.
remote: error: File build/Desktop_Qt_6_8_0-Debug/mapper_app/mapper is 117.74 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File build/Desktop_Qt_6_8_0-Debug/mapper_app/mapper is 117.71 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To https://github.com/allenck/mapper.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/allenck/mapper.git'
allen@ubuntu:~/Projects/Mapper/mapper_QT$ git rm --cached build/Desktop_Qt_6_8_0-Debug/mapper_app/mapper
allen@ubuntu:~/Projects/Mapper/mapper_QT$ ls -l build/Desktop_Qt_6_8_0-Debug/mapper_app/mapper
-rwxrwxr-x 1 allen allen 123726384 Oct 29 20:37 build/Desktop_Qt_6_8_0-Debug/mapper_app/mapper
allen@ubuntu:~/Projects/Mapper/mapper_QT$ ls -l File build/Desktop_Qt_6_8_0-Debug/mapper_app/mapper

注:该问题文件为不应纳入仓库的可执行文件,已从本地删除,仓库地址为https://github.com/allenck/mapper

解决方法

1. 清除Git历史中的超大文件

git rm --cached仅移除暂存区的文件,但该文件可能已存在于过往提交历史中,GitHub会检查所有历史提交的文件大小。需彻底清理历史记录:

执行命令彻底移除历史中的目标文件:

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch build/Desktop_Qt_6_8_0-Debug/mapper_app/mapper' --prune-empty --tag-name-filter cat -- --all

清理本地仓库冗余数据:

git reflog expire --expire=now --all && git gc --prune=now --aggressive

2. 添加忽略规则防止误提交

在仓库根目录的.gitignore文件中添加以下内容,避免后续提交build目录下的文件:

build/

3. 强制推送更新

完成上述操作后,强制推送本地分支到远程仓库:

git push origin master --force

内容的提问来源于stack exchange,提问作者Allen Kempe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 18:31:20