I've successfully (I think!) removed large files from a gitlab project mirrored on my local drive using BFG. I don't want to replace the existing gitlab project (for safety reasons), but instead want to push to a new test gitlab project. Here's the commands I've done successfully so far:
git clone --mirror git@git.domain.com:architecture-team/IOMobile.git
java -jar bfg.jar --strip-blobs-bigger-than 100M IOMobile.git/
cd IOMobile.git
git reflog expire --expire=now --all
git gc --prune=now --aggressive
Those commands seem to have done the trick, now how do I reset the origin to:
git@git.domain.com:architecture-team/testiomobile.git
...and then push the mirror into the new project? I'm not sure how to reset the origin on a mirror and want to make sure I don't change the original project.
Do I just do a simple
git push
or do I need
git push --mirror
Thanks for any help -Owen
I think in this case it does not matter if you specify --mirror
or not. Since you cloned it already with the --mirror
flag, a normal git push will update all refs on the remote server. This is also described at the bfg docs: https://rtyley.github.io/bfg-repo-cleaner/
But there is a gotcha you could run into. If you see this error message while pushing:
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
Then you have to enable Allow force push
option in the GitLab project settings at URL https://git.domain.com/architecture-team/testiomobile/-/settings/repository
After the push you should disable the Allow force push
again.