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

Hi,  
It looks like I am facing the same issue.  
My git repo was 3.3Go.

I used bfg to remove one large file  
then use git reflog and git gc  
then push -f to rewrite history

It worked for develop branch, but now I can't do the same things for master branch because the size is now 4.04Go so my push is rejected.  

I used git count-objects obtaining:

```
count: 0
size: 0 octet
in-pack: 7360
packs: 1
size-pack: 789.02 Mio
prune-packable: 0
garbage: 0
size-garbage: 0 octet
```

<br />

<br />

[@kelkk](/t5/user/viewprofilepage/user-id/4692809) I tried a solution with an other git repo.  
After using bfg, git reflog and git gc, i create an other git repo and use on my initial local repo:
> git remote set-url origin git@bitbucket.org:me/my-new-git.git
>
> git push -f --all origin

it worked, but I don't want to redo all my git settings, variables, etc...


Answers:
author: Theodora Boudale
body: Hi [@Nicolas Eche](/t5/user/viewprofilepage/user-id/4704982),

I checked the repositories that your Bitbucket Cloud account has access to and I found one over the 4 GB limit. I ran a git gc on it and its size is 795.5 MB now.

When you rewrite history and push your changes, the remote repo's size will go up because it will contain both old and new references. A git gc is needed on the remote repo for the olds refs to get removed and for the repo's size to get reduced.

If you need to remove files from the history of all branches, I would recommend running BFG on a mirror clone (as mentioned here: <https://rtyley.github.io/bfg-repo-cleaner/>), this way you will not have to repeat the process for every branch.

If you plan to use BFG again to reduce the repo's size further, please feel free to let me know after you push your changes and I can run another git gc. Alternatively, you can also create a ticket with the support team and ask them to do so, since the repo is owned by a workspace on a paid billing plan. You can create a ticket via <https://support.atlassian.com/contact/>, in "What can we help you with" select "Technical issues and bugs" and then Bitbucket Cloud as product. In "What is the impact to your business?" please make sure to select Level 1 if the repo is over the size limit and you are blocked from working.

We have a feature request to allow users to initiate a git gc for remote repositories:

* <https://jira.atlassian.com/browse/BCLOUD-11593>

You can add yourself as a watcher in that feature request by selecting the **Start watching this issue** link if you'd like to get notified on updates.

Just a heads up, I moved your post to a new question. It's best to create a new question for your issue instead of replying to an existing question, as this way your new question will be visible to my colleagues as well when I'm out of office (and you'll get help faster if I'm out of office for a long time).

If you have any questions, please feel free to let me know.

Kind regards,  
Theodora

comments: author: Nicolas Eche
body: Hi [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086),

Thanks for your quick answer last week it really helped me.  
I've started watching the issue, hoping we will be able to use it soon.

I've finished my bfg cleanings so if it is possible to re-run git gc it will be perfect.

<br />

Thanks again,  
Best regards,  
Nicolas


author: Theodora Boudale
body: Hi Nicolas,

You are very welcome!

I can of course run another git gc; would you mind sharing the last two letters of the repo's name or the repo's size in Bitbucket Cloud, so I can identify which one it is and run the git gc?

Last week I could identify it based on the repo size you mentioned, but I cannot recall now which one it is.

Please keep in mind also that the repo will go in read-only mode while the git gc is running, to avoid any corruption.

Kind regards,  
Theodora


author: Nicolas Eche
body: Hi,  
The last two letters of the repo are 'ro'


author: Theodora Boudale
body: Thank you Nicolas, I ran a git gc on the repo and its size is 46.0 MB.

Does this agree with the size of your local repo? Please feel free to let me know if you need anything further.

Kind regards,  
Theodora


author: Nicolas Eche
body: Thanks a lot,  
It agree with the size of my local repo.  

Kind regards,  
Nicolas


author: Theodora Boudale
body: That's good to hear and you are very welcome.

Please feel free to reach out if you ever need anything else!

Kind regards,  
Theodora