My Repo size exceed 4GB limit and I deleted my wrong remote branch
Asked by Le Ni:

Hi dev support.  
I have wrong commit that push around 1GB to remote repo and my repo size exceed 4GB limit. I try to fix the commit locally as suport center told but can not force push so I decide to deleted the remote branch contain the oversize commit but nothing change.  
Then I try to create branch with same name in remote repo but it seem that repo size not reduce.  
Now I can not do anything to fix the problem.

Can anyone help me please.


Answers:
author: Theodora Boudale
body: Hi [@Le Ni](/t5/user/viewprofilepage/user-id/5105097) and welcome to the community!

Yes, I can assist you with this. I can see that your Bitbucket Cloud account has access to quite a few workspaces and repositories. Could you please let me know the last two letters of the repo and the last two letters of the workspace this repo belongs to, so I can identify the one you are talking about, and run a git gc for it?

Kind regards,  
Theodora

comments: author: Le Ni
body: [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) Thank you. Because I join so many workspace, the last 4 letters of my workspace is **saco** and the last 4 letters of my repo is **main**


author: Theodora Boudale
body: Hi [@Le Ni](/t5/user/viewprofilepage/user-id/5105097),

Thank you for the info. I ran a git gc for the repository and its size has been reduced. It's under the 4 GB limit now, but still quite large.

Is the large commit still part of the repo's history? If you go to the repo on Bitbucket Cloud website, and then open the **Commits** page of the repo, do you see the large commit listed there?

Kind regards,  
Theodora


author: Le Ni
body: Thank you so much for your support. This repo has many of our mistakes, many large commits months ago.


author: Le Ni
body: Those large file is start point of many commits but nearly commits does not has any big size file. I dont know how to reduce the repo size now. Today I add a hundreds MB commits and you did gc but the size not reduce same size as my mistaken commit.


author: Le Ni
body: We do not use these really large file anymore, deleted on our repo but it still living in bitbucket in many branch and I do not know how to remove all of it too


author: Theodora Boudale
body: Hi [@Le Ni](/t5/user/viewprofilepage/user-id/5105097),

Committing file deletions is not going to remove these files from the repo's history. This is only possible if you rewrite history in the repo, with a tool like [BFG](https://rtyley.github.io/bfg-repo-cleaner/).

I made a detailed post about this in a different question:

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

It's quite long, but I would suggest reading all of it to better understand what you need to take into account. If you have any questions about the content, please feel free to let me know.

A few things that I mention in that post as well:

* Always take a backup of the repo prior to doing a history rewrite  

* History rewrite will change commit hashes, it's good to communicate this to your team so there are no surprises, and also so that they take a fresh clone of the repo after you push your changes (and avoid pushing the old history back)  

* If you push to the Bitbucket repo after doing a history rewrite, the repo size will probably go up again and the repo will need another git gc. You can let me know here and I can run it again for the repo.

Kind regards,  
Theodora


author: Le Ni
body: [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) I already try BFG but as you said, the repo size go up and need another git gc. I'll folk this directory to my another workspace today and do BFG one more time. After everything pushed, I'll ask for your help . Thank you again


author: Le Ni
body: [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) I did folk my old repo to another repo, then do BFG tutorial and already push. Can you help me check this repo and run git gc on it.  
Workspace last 4 character is saco and repo last characters is main_new


author: Theodora Boudale
body: Hi [@Le Ni](/t5/user/viewprofilepage/user-id/5105097),

I ran a git gc on both repositories:

* Repo with a name ending in **main** shows on change in size, it is 4 GB
* Repo with a name ending in **main_new** now has a reduced size, 2.9 GB

Does only the second repo (**main_new**) have the changes with BFG?

Please feel free to let me know how you would like us to proceed now:

* If the fork seems to be in good shape, I can temporarily increase the repo size limit for the main repo, so you can push your changes to that one, please let me know.
* If you would like to remove more files with BFG from the **main_new** first, please let me know when you push so I can run another git gc.

Kind regards,  
Theodora


author: Le Ni
body: I asked my team to move to folk repo, everything seem good now. Thank for supporting me


author: Theodora Boudale
body: You are very welcome [@Le Ni](/t5/user/viewprofilepage/user-id/5105097). If you need anything further, please feel free to reach out!


author: Le Ni
body: [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086)   
Hi, I saw support help git gc on some project. I dont know how long does it take for a support member to see my disscusstion so I tag you here. Sorry for that


Tags: bitbucket-cloud

cloud