Deleting Files from oversized GitLab Projects
Preparations
For this tutorial you need to have a Git client installed on your computer, and a project cloned (e.g. with TortoiseGit). The Git Client also includes a Git Shell on Windows, which is required for this tutorial. To start the Git Shell, right-click on the folder containing the project in Explorer and select "Git Bash here". This will open the Git Bash with the path set.
After executing the commands below, you should also be asked for the current size of the repo, so that you can make a simple before/after comparison. The following command helps you to do this:
git count-objects -v |
Cleaning up the repo
For the following command the path to the file to be deleted must be known. This can be found by searching GitLab within the commit that added the oversized file(s) to the repo. If this path is known, the following commands must be used:
git filter-branch --tag-name-filter cat --index-filter 'git rm -r --cached --ignore-unmatch /pfad/zur/datei' --prune-empty -f -- --all rm -rf .git/refs/original/ git reflog expire --expire=now --all git gc --prune=now git gc --aggressive --prune=now |
With a new
git count-objects -v |
it is necessary to check whether the space consumption has become smaller. If this is the case, the repo can now be started with a
git push origin --force |
can be transferred to the server. If this doesn't work in the console, because it can't access Pageant, you can also push using TortoiseGit, here simply check "Force" in the Git Sync dialog before the push.
Now GitLab should also show the updated size in the repo overview and the project should no longer be over quota.
If after this operation the project has not become smaller, but possibly even larger, please contact the IT-SD.