I faced a similar issuer when trying to delete some big files from gitlab by rewriting the history, following the procedure here: https://docs.gitlab.com/ee/user/project/repository/reducing_the_repo_size_using_git.html
IMPORTANT: Before starting use gitlab export function to export your project, these steps went wrong for me many time before I figured it out.
The issue I faced as mentioned by others is that you can not rewrite read-only refs specifically does for PRs (merge requests as they are called in gitlab)
The obvious idea that come then is to create a new repo, but this would loose all the issues, releases...
Fortunately, gitlab allows to export you repo with all this metadata unto a zip file, that contains all the git bundled, (more info here about git bundle).
A bundle is basically a full archive of the repo, and ou can clone form it:
git clone --mirror ./project.bundle
Not you have a mirror of your project (the same way if you have mirror cloned form the server), and you can use git filter-repo
or (BFG)[https://rtyley.github.io/bfg-repo-cleaner/] as explaind in the docs, to find the biggest files and delete them from history.
use du -h
before and after to make sure that the size of your repo is really smaller, now you can create a new git bundle with:
git bundle create --progress project.bundle --tags --branches master
although I recommend handling all branches before this procedure to avoid messing up branches.
You can replace project.build in the export downloaded from gitlab (ie create a new tar.gz with exact same structure, be careful of prefix...)
this can be done by:
tar -xvzf project_name...export.tar.gz
replace the project.bundle
cd project_name...export
tar -cvzf updated.tar.gz . # important to avoid messing up tar structure
And the re-importing the project.
You can rename you project to PROJECT_NAME-bkp in gitlab, and reimport with same name as before.
Hope it save someone else the time.