Joe Scotto
Joe Scotto

Reputation: 10877

Can't push to >2gb repo after clearing files with BFG

I accidentally pushed some large files that were supposed to be ignored to git and as a result my repo is over 2gb. I'm trying to clear some files out with BFG and have been able to clear around 400mb but when trying to push I get the following error

Counting objects: 1510, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (621/621), done.
Writing objects: 100% (1510/1510), 373.84 MiB | 11.69 MiB/s, done.
Total 1510 (delta 879), reused 1403 (delta 778)
remote: Resolving deltas: 100% (879/879), completed with 95 local objects.
remote: repository is in read only mode (over 2 GB size limit).
remote:
remote: Learn how to reduce your repository size: https://confluence.atlassian.com/x/xgMvEw.
To https://bitbucket.org/HIDDEN/REPO.git
 ! [remote rejected]   feature/feature -> feature/wikitude (pre-receive hook declined)
error: failed to push some refs to 'https://bitbucket.org/HIDDEN/REPO.git'

I read online that a force push could solve this but I feel that might be risky, I do have a backup with --mirror of my repo before the file deletions with bfg.

Upvotes: 2

Views: 1754

Answers (2)

Joe Scotto
Joe Scotto

Reputation: 10877

Had to reach out to BitBucket to clear the repo on their end first before allowing me to push.

Upvotes: 1

Code-Apprentice
Code-Apprentice

Reputation: 83527

By removing files, you have created new commits and an entirely new history than what the remote repo has for the branch. You must use git push -f in order to force push your changes.

The risk here is that if anyone else has already pulled your changes they will need to do some work to clean up the large files in their repo, too. If you are the only one working on this project, then you don't need to worry.

Upvotes: 1

Related Questions