git gc on remote

Kai Aoki
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 26, 2025

Hi, Atlassian team.

I need to run git gc on the remote repository on bitbucket. What should I do?

The repo size on my local is just less than 100 MB but it is 2.8GB on the bitbucket.

How can I fix it? Thank you.

 

Best,

Kai

2 answers

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 26, 2025

Hi Kai and welcome to the community!

I ran a git gc on your repo and its size has been reduced but not by a lot. Its size is 2.2 GB now.

Could you please let me know the following:

1. Did you rewrite history to remove large files from the repo?

2. Can you please take a mirror clone of the repo and then check the size of that?

You can get a mirror clone with the command

git clone --mirror <repo-url>

Then, navigate to the directory of the mirror clone and run the command

git count-objects -Hv

What output do you get from the last command?

A mirror clone is a bare repo with no working directory and with all the remote branches and it would be useful to get the size of that with the command I provided, to understand if large files still exist on your remote repo's history or if the difference in size is due to another reason (e.g. large files still referenced by PRs).

Just a heads up, I removed the repo details from your answer to protect your privacy.

Kind regards,
Theodora

Kai Aoki
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 26, 2025

1. Yes, I tried to rewrite the history to remove large files.

We used to have large ml models and datasets commited in the repo which caused this size bloat. This has been completely removed from the repo though and now the models and datasets sit in aws s3.

Also, I tried to git push --force to master branch expecting any decresement of the repo size, but nothing happend.

 

2. I cloned the git repository using --mirror flag and run the git count-objects -Hv command. The result is this.

count: 0
size: 0 bytes
in-pack: 20963
packs: 1
size-pack: 16.76 MiB
prune-packable: 0
garbage: 0
size-garbage: 0 bytes

 

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 26, 2025

Hi Kai,

Thank you for the details.

In this case, I think the most likely reason for the difference in size is that the large files you have cleared may still be referenced in certain Pull Requests of the repo.

If that is the case, then the only way to reduce the repo size would be by deleting these PRs. Is this something you would consider?

If so, I can create a support ticket on your behalf. One of my colleagues can look into it and confirm if it's indeed the PR refs contributing to the repo size, and share with you which PRs they are, so you can make a decision. We will only delete PRs with your consent.

Please feel free to let me know if you'd like me to create a support ticket for this.

Kind regards,
Theodora

Kai Aoki
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 26, 2025

Hi, Theodora.

Thank you so much for clarifying everything. Yes, I agree with your opinion.

You can create a support ticket on my behalf. And then your colleagues can let me know which PRs is in large size. Once I make a decision, then you can delete those PRs.

Best regards,

Kai

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 26, 2025

Hi Kai,

Of course. I created the support ticket on your behalf using the email address of you community account.

You should have received an email with a link to the support ticket, and you can also see the ticket here after logging in:

I added an internal note for my colleagues where I explained what we discussed and also that the git gc was run for the repo. One of them will look into it and reach out to you via the support ticket.

Please feel free to let me know if you have any questions!

Kind regards,
Theodora

0 votes
Kai Aoki
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 26, 2025

Please execute Git GC on this repository

workspace -  <redacted>

repository - <redacted>

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events