Run GC on my repo
Asked by Sumeet.d.kumar:

Hi Team Atlassian,

I have cleaned my repository from local through bfg and pushed on the server. Can you please run gc on these repos:

git@bitbucket.org:\<redacted\>.git and

git@bitbucket.org:\<redacted\>.git

Thanks,

Sumeet Kumar


Answers:
author: Patrik S
body: Hello [@Sumeet.d.kumar](/t5/user/viewprofilepage/user-id/5427454) ,

thank you for reaching out!

I have executed a GC on both the repositories you shared, and the size was reduced from about \~2.6GB to \~2.4GB.

As the size didn't reduce much, I would suggest using the following command to list the top 50 largest files in the repo, and use BFG to either delete those files or move them to LFS to further reduce the repository 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 \
| tail -n 50 \
| cut -c 1-12,41- \
| $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
```

Thank you, [@Sumeet.d.kumar](/t5/user/viewprofilepage/user-id/5427454) !

Patrik S

comments: author: Sumeet.d.kumar
body: Hi [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) ,

Does having too many branches also increase the bitbucket repo size? Currently, we have around 4000 branches on my repo. Will cleaning the unused branches help me significantly in reducing the bitbucket repo size?

Thanks,

Sumeet Kumar


author: Sumeet.d.kumar
body: Hi [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) ,

I used BFG Repo-Cleaner to delete some files from my Git repository. After running 'git reflog expire --expire=now --all \&\& git gc --prune=now --aggressive'  
to perform garbage collection, I still see some same files when I run the \`git rev-list --objects --all\` command. Is this expected behavior? What steps should I take to ensure these files are completely removed from the repository history?

Thanks,

Sumeet Kumar


author: Patrik S
body: Hey [@Sumeet.d.kumar](/t5/user/viewprofilepage/user-id/5427454) ,

After the deletion with BFG and the local GC, the files should now show up in the git-rev-list command.

Could you please confirm if you followed the steps outlined in the below article when deleting those files?

* [How to remove files from the commit history in Bitbucket Cloud](https://confluence.atlassian.com/bbkb/how-to-remove-files-from-the-commit-history-in-bitbucket-cloud-1252001212.html)


author: Sumeet.d.kumar
body: Hi [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) ,

Yes, I followed the similar steps. Apart from point 2, I did the same. For file names, I gave wildcard names like abc-\*.tgz. For some of the files which got deleted, it is not coming in the git-rev-list command. However, for others, it does show.

What steps can I follow apart from this?

Thanks,

Sumeet


author: Patrik S
body: Hello [@Sumeet.d.kumar](/t5/user/viewprofilepage/user-id/5427454) ,

The steps outlined in that article should work for removing the files. I see you have access to a workspace with an active Bitbucket subscription that is entitled to standard support, so to investigate this further, I will be raising a support ticket for you using the same email used to post this question

You should be receiving the support link soon, but in case you don't, please let me know so I can share it with you here (only you and Atlassian staff can access it).

Thank you, [@Sumeet.d.kumar](/t5/user/viewprofilepage/user-id/5427454) !

Patrik S


Tags: bitbucket-cloud

cloud