Need GC on remote
Asked by justin.charbonneau:

Dear Bitbucket support team,

We have a repo that has over 2 GB (thus the warning).

I wasn't quite 100% sure on the sequence of git commands to run to first delete select large files and clean the history. I was able to clean it following the instructions below and removed large CSV files from my repo **delete_history_test.**The repo is still 66MB and should be much smaller. Can you run the GC on that repo, so I have proof that these instructions work? After which I'll talk to my team to clean up our repo and I suppose we will need to trigger a GC next week.

**Dummy Exercise:**   

What I wanted to have is

* **main** branch with checked-in large files.
* **infected**branch with still work to do (but everything committed and pushed to remote)

The large files exist in both the main and the infected branches, so I did:

* git checkout main
* git rm large_file.csv
* git commit -m "delete large file"
* git push
* git checkout infected branch
* git rm large_file.csv
* git commit -m "delete large file"
* git push

Then, I clean the history doing:

* git checkout main
* git filter-branch -f --prune-empty --index-filter "git rm --cached -f --ignore-unmatch large_file.csv" --

* git push -f
* git checkout infected branch
* git filter-branch -f --prune-empty --index-filter "git rm --cached -f --ignore-unmatch large_file.csv" --
* git push -f

I suspect after this point, all of the histories should be clean and I need to trigger the GC from the remote which I can't trigger.

Can you trigger it to this repo **delete_history_test**so I can make sure it works?

Thanks,

Justin


Answers:
author: Theodora Boudale
body: Hi Justin,

I ran a git gc for this repo and its size is 58.6 MB now.

Can you take a mirror clone of the repo and execute **git count-objects -Hv** in the mirror clone directory, and let me know what you see in the output?

Kind regards,  
Theodora

comments: author: justin.charbonneau
body: Hi Theodora, here's my output from that command:  

![output_command.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/202181i94D4D46DF2E9DC09/image-size/large?v=v2&px=999 "output_command.PNG")

How come the repo is still 58MB ? There is barely anything in the repo?


author: Theodora Boudale
body: Hi [@justin.charbonneau](/t5/user/viewprofilepage/user-id/4966997),

In your first post, you mentioned that the repo has more than one branch.

**1.** Does your clone (where you executed git count-objects -Hv) have all branches locally?

If you haven't pulled all remote branches locally, then the local repo will be of a smaller size.

**2.** Could you please take a mirror clone of the repo **delete_history_test**

```
git clone --mirror <repo_url>
```

and then run **git count-objects -Hv** in that mirror clone, and let me know what the output is?

Kind regards,  
Theodora


author: justin.charbonneau
body: Hi [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086)  

Initially yes it had more than one branch. In the meantime I had discovered that maybe I could use LFS to move those files there, and I tried to play around with it. At one point in time, the repo went down to 60 KB when I had first created another branch and installed LFS and added the gitattributes for CSV files, but after merging it, the repo went back to 66MB. I tried to reproduce but I couldn't. In the end I deleted the LFS file and tried to clean it up to bring it back to that initial state.   

Here's a screenshot of the commands you told me to run:

![screenshot bitbucket.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/202411i6FD99FEC551E384B/image-size/large?v=v2&px=999 "screenshot bitbucket.PNG")

<br />


author: Theodora Boudale
body: Hi [@justin.charbonneau](/t5/user/viewprofilepage/user-id/4966997),

Thank you for the info.

Since the mirror clone also shows a size of 8.96 KB, we will need to inspect the remote repo to see what takes up extra space.

I cannot access your repo in order to check that, we need a support ticket in order to be able to access a remote repo.

<br />

I see that the test repo **delete_history_test** belongs to your personal workspace, but there is no other repo there over 2 GB.  
I also see that you are a member of a workspace on a paid billing plan.  
Does the repo that has a size of over 2 GB belong to that workspace?

If so, what you can do is:

* talk with your admins and [transfer](https://support.atlassian.com/bitbucket-cloud/docs/transfer-repository-ownership/) **delete_history_test** repo to the workspace on the paid billing plan
* you can then create a ticket with the support team to look into the issue with the size. You can create a ticket via <https://support.atlassian.com/contact/#/>, in "What can we help you with?" select "Technical issues and bugs", then Bitbucket Cloud as product, and enter the workspace URL of the paid billing plan.

However, if **delete_history_test** repo is not related to a repo on that paid workspace and it's your personal repository, please feel free to let me know and I can create the support ticket for you.

Kind regards,  
Theodora


Tags: atl-rvw

bitbucket-cloud

cloud

garbage-collection