Remote Garbage Collection
Asked by Ryan Dorman:

A repository I am working on had large files in the commit history causing it to take up a large amount of space in BitBucket. That history has been removed, but I am unable to get the remote repository to recognize it.

Does BitBucket's remote garbage collection run on a schedule automatically, or how do I make that \`git gc\` happen?

Thanks!


Answers:
author: Theodora Boudale
body: Hi Ryan!

I saw a repo with a size over 2 GB (among the ones you have access to) and I ran a git gc for it. I assumed that was the one needing a git gc, but if I was wrong, please post the last two letters of the repo name (or any combination of letters that will help me identify it) that you need the git gc for.

In case this was the correct repo, its size has been reduced but not a lot. What is the size you expected to see? And how did you remove large files from the repo?

Kind regards,  
Theodora

comments: author: Ryan Dorman
body: Theodora,

The repo ends in 'te'.

I believe it's the only repo I have access to that is over 2GB so you may have been looking at the correct one. I see this morning that the size has reduced by .3GB - possibly since you ran \`git gc\`.

I would expect the size to reduce substantially though - to less than a GB. The source code is only \~20 MB and I removed all old branches except \`master\`. I also backed up the git history locally and then truncated in the repo so there is only 1 commit currently. Yet, the size it is taking up is still substantial.

Is it possible the old PRs are causing unexpected space to be used? If so, is it possible to delete all old PRs to see if that frees up the space. I can only approve or deny them on my end and can find no documentation on to actually delete them.

I am trying to avoid deleting the repo and re-creating it as it would require me to re-setup aspects of the CI/CD pipeline it is involved in.

Thank you for your help!

Ryan


author: Theodora Boudale
body: Hi Ryan!

Pull requests do not count toward the repository size.

If I understand correctly, the repo now has only one branch (master) and only 1 commit on this branch?

Could you please do the following:

* Take a mirror clone of the repo (**git clone --mirror \<repo_url\>**)
* Navigate then inside the directory of the mirror clone
* Inside that directory, execute the command **git count-objects -Hv**

This command will show info about the repo's size. What output do you get from this command?

I don't have access to your repo to do this myself. I want to see if there is a discrepancy between the size we report and the size you see in a mirror clone to understand where the problem lies.

Kind regards,  
Theodora


author: Ryan Dorman
body: Theodora,

Thank you again for helping me figure this out. I followed the steps you outlined and here's the output I received:

```
count: 0
size: 0 bytes
in-pack: 301
packs: 1
size-pack: 21.93 MiB
prune-packable: 0
garbage: 0
size-garbage: 0 bytes
```

Regards,

Ryan


author: Theodora Boudale
body: Hi Ryan,

Thank you for the output. Since the size of the mirror clone is that small, something is taking up space in the remote repo that the git gc I run does not remove. I am going to create a support ticket on your behalf using the email of your community account to investigate this further and try to resolve it.

You are going to receive an email with a link to the ticket. Just in case you don't, please feel free to let me know and I can post the ticket URL here. The ticket will be visible to you and Atlassian staff, no one else can view its content even if they have the URL.

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud