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

无法从GitLab仓库清理冗余大文件,推送仍遭拒绝

问题描述

按照GitLab文档使用git filter-repo命令清理当前分支的冗余大文件,同时移除了.gitattributes中对应大文件的配置行,但推送修改时仍收到大小超限错误:

batch response: Your push has been rejected, because this repository has exceeded its size limit of 10 GiB by 2.7 GiB. Please contact your GitLab administrator for more information

终端操作及输出如下:

$ git filter-repo --strip-blobs-bigger-than 5M --prune-degenerate always --force
Processed 2862 blob sizes
Parsed 491 commits
New history written in 0.64 seconds; now repacking/cleaning...
Repacking your repo and cleaning out old unneeded objects
HEAD is now at aeh9h85 Added model files to model folder
Enumerating objects: 6102, done.
Counting objects: 100% (6102/6102), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2080/2080), done.
Writing objects: 100% (6102/6102), done.
Total 6102 (delta 3871), reused 6071 (delta 3844), pack-reused 0
Completely finished after 1.35 seconds.
$ git remote -v
$ git remote add origin https://gitlab.com/xxx/internal/yy/test.git
$ git remote -v
origin  https://gitlab.com/xxx/internal/yy/test.git (fetch)
origin  https://gitlab.com/xxx/internal/yy/test.git (push)
$ git push --set-upstream origin test-changes -f
batch response: Your push has been rejected, because this repository has exceeded its size limit of 10 GiB by 2.7 GiB. Please contact your GitLab administrator for more information.                                                         
error: failed to push some refs to 'https://gitlab.com/xxx/internal/yy/test.git'
解决方法
  • 确认本地仓库实际大小
    执行命令检查本地仓库占用空间,验证git filter-repo是否生效:

    du -sh .git
    

    如果大小仍接近12.7GiB,说明过滤未生效,可能是大文件存在于其他分支/标签中。

  • 清理所有分支和标签的大文件
    仅清理当前分支无法解决问题,需对所有分支、标签执行过滤:

    # 列出所有本地分支
    git branch -a
    # 逐个切换分支执行过滤
    git checkout <branch-name>
    git filter-repo --strip-blobs-bigger-than 5M --prune-degenerate always --force
    

    处理标签:

    git tag
    git checkout <tag-name>
    git filter-repo --strip-blobs-bigger-than 5M --prune-degenerate always --force
    git tag -f <tag-name>
    
  • 彻底清理本地冗余对象
    过滤完成后,清除本地未引用的历史对象:

    git reflog expire --expire=now --all
    git gc --prune=now --aggressive
    
  • 清理Git LFS残留对象
    移除本地LFS配置并推送删除操作:

    git lfs rm --all
    git push origin --force --all
    git push origin --force --tags
    
  • 联系GitLab管理员
    若以上操作后仍报错,说明远程仓库的历史未引用对象未被清理(GitLab不会自动触发垃圾回收),需管理员协助清理冗余空间。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.11 17:42:37