Repo size exceeds 4GB, cant push fixes
Asked by Xtend:

Hello,

Same issue here, I ran a bfg clean up to reduce size, and now i'm unable to push the changes because the size is over 4gb, I have the auto gc enabled but still nothing reduced.

Could you check please? the last two letters of the repo are "al"

Best regards


Answers:
author: Theodora Boudale
body: Hi [@Xtend](/t5/user/viewprofilepage/user-id/725309),

I ran a git gc for your repo and although its size has been reduced, it is still over the 4 GB limit.

Since you have reduced the repo's size locally, I have temporarily increased the repo size limit to 5 GB so you can push your changes.

Please note that when you push these changes the repo size will most likely get increased again because the remote repo will contain both old references (prior to history rewrite) and new ones (after history rewrite).

Another git gc will be needed on the remote repo to have the old references removed. Please let me know when you push and I can run another git gc for the repo.

Just a heads up, I moved your post to a new question. It's best to create a new question if you need assistance with a certain issue as a new question will have better visibility to the rest of the Atlassian team if I'm out of office, and also because a post can become difficult to follow if we work on multiple users' issues in that post.

Kind regards,  
Theodora

comments: author: Xtend
body: Hello Theodora,  
I did the push, you can run the gc again

thanks


author: Theodora Boudale
body: Hi [@Xtend](/t5/user/viewprofilepage/user-id/725309),

I ran another git gc for the repo, but its size is still over 4 GB.

Could you please let me know

**1.** What is the output of the following command in the local clone where you executed BFG?

```
git count-objects -Hv
```

**2.** Did you run BFG in a mirror clone of the repo?

**3.** If you take a mirror clone of the repo now

```
git clone --mirror <repo url>
```

and then navigate to the directory of that mirror clone, what is the output of **git count-objects -Hv** in that directory?

Kind regards,  
Theodora


author: Xtend
body: Hi Theodora,   
thank you for your time.

On the mirror clone:

$ git count-objects -Hv  
count: 0  
size: 0 bytes  
in-pack: 35825  
packs: 3  
size-pack: 4.48 GiB  
prune-packable: 0  
garbage: 0  
size-garbage: 0 bytes


author: Theodora Boudale
body: Hi [@Xtend](/t5/user/viewprofilepage/user-id/725309),

Thank you for your reply.

Since the size in the mirror clone shows the repo to be over 4 GB, the push you did earlier did not reduce the remote repo's size.

Please note that I have changed the repo's size limit back to 4 GB.

I would suggest checking this reply of mine to a different post with steps on how to identify large files and reduce the repo's size:

* <https://community.atlassian.com/t5/Bitbucket-questions/Revert-bitbucket-repository-state-to-one-day-prior/qaq-p/1908360#M76762>

If you use BFG to remove certain files, please make sure that you run it in a mirror clone of your repo, and also that your latest commit is clean with none of the undesired data in it.

Step-by-step instructions for BFG, along with some examples, can be found here:

* <https://rtyley.github.io/bfg-repo-cleaner/>

After you follow all the steps of running BFG, you can check the size of the mirror clone where you ran it with **git count-objects -Hv**, to confirm if it is below 4 GB.

Please let me know then, and I can temporarily increase the repo size limit again so you can push your changes.

Kind regards,  
Theodora


author: Xtend
body: I already did the BFG clean up and it has still more than 4GB...

If I remove all git references manually, the size is 2.6Gb ( you can check the new repo with suffix "_New") it's a copy of the old without ref

Thanks


author: Theodora Boudale
body: Hi [@Xtend](/t5/user/viewprofilepage/user-id/725309),

Even though I can see the repo's size, I cannot view its content.

A repo's size may be large because it has large/binary files, or because it has a lot of references or a combination of those.

Do you version any large and/or binary files in the repo?

You can use the following command in a clone of the repo to see its files and their respective size:

```
git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \
| sort --numeric-sort --key=2 \
| cut -c 1-12,41- \
| $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
```

If you see any large/binary files and you need to version them, then you may want to consider tracking them with Git LFS.

We have the following guide on how to migrate files to Git LFS in an existing repo:

* <https://support.atlassian.com/bitbucket-cloud/docs/use-git-lfs-with-existing-bitbucket-repositories/>

Files tracked with Git LFS do not count towards the repository size, so the repo's size should get reduced.

Git LFS files count towards the workspace's LFS storage.

Workspaces on the free plan have 1 GB of Git LFS, but you can purchase additional LFS storage if you need it. You can find more details on billing plans and the available LFS storage here:

* <https://support.atlassian.com/bitbucket-cloud/docs/manage-your-plan-and-billing/>

Kind regards,  
Theodora