I'm trying to remove some unwanted large files from this branch using the git filter-repo
command (git filter-repo --strip-blobs-bigger-than 5M --prune-degenerate always --force
) as stated in this GitLab docs & also removing the lines of those large files from this .gitattributes
file however when I try to push the change, I still get this error:-
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
Following is the terminal output:-
$ 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'
I followed these steps and it worked for me:-
Install git-filter-repo
first and follow the steps below to clear the unwanted LFS:-
git filter-repo --force --path /lfs_dir --invert-paths
assuming your LFS are inside the directory (/lfs_dir) or modify the above command to point to right directory of LFS that needs to be removed
Then, remove the lines of unwanted LFS from .gitattributes file, and then execute following commands
git add .
git commit -m <commit message>
git push --force --all origin
git reflog expire --expire=now --all
git gc --prune=now --aggressive
Go to GitLab → Project Repository Settings → General → Advanced and click on ‘Prune unreachable objects’ to prune them now manually.