Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

My repo size is 2.15GB how i can reduce it

Ahmad Kabeer Shaukat February 29, 2024

I have applied several methods based on documentation in the URL provided by bitbucket as a repo size warning message 

I tried below 

To be safe I forked the repo to my account and applied the below code so that 
i could see the solution works or not but to no avail even this solution increased by repo size to 2.19


but could not find any 
git clone git@bitbucket.org:workspace-id/repo.git cd crepo/ git checkout dev && git pull git gc java -jar ../bfg-1.14.0.jar --strip-blobs-bigger-than 20M git reflog expire --expire=now --all && git gc --prune=now --aggressive

2 answers

1 vote
Perisic Nikola
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 29, 2024

Welcome to the community @Ahmad Kabeer Shaukat !

I hope this page resolves your issue: https://support.atlassian.com/bitbucket-cloud/docs/reduce-repository-size/

Ahmad Kabeer Shaukat February 29, 2024

i tried everything on this page 

i created a temp repo and pushed all my actual repo content 
and it shows a size of 7.9 MB 

however even after deleting all my tags and a lot of branches I was unable to reduce my git repo size 

Ahmad Kabeer Shaukat February 29, 2024

git ls-tree -r --long HEAD | sort -k 4 -n -r | less
this commands list all files with ascending order to there file size and there is 4 files above 20 MB in this list 

Ahmad Kabeer Shaukat February 29, 2024
0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 4, 2024

Hi @Ahmad Kabeer Shaukat,

If you rewrite history and push to the remote, its size will increase because the remote repo will have both old references (before history rewrite) and new ones (after history rewrite). A git gc is needed on the remote repo to remove any old references. While end users can run a git gc on their local repo, they can't trigger a git gc on the remote repo.

I see that you have deleted the fork you created. Please let me know when you push the BFG changes to the repo it was forked from, and I can run a git gc for it.

Just a heads up, I removed the workspace id and repo name from your post to protect your privacy.

Kind regards,
Theodora

Ahmad Kabeer Shaukat March 15, 2024

@Theodora Boudale Thanks for your kind response.

Is there anything that can be done from your side because I failed to reduce the repo size 
either it could be guidance or some direct help 
the goal is to reduce repo size we want to remove all history except for the last month 

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 15, 2024

Hi @Ahmad Kabeer Shaukat,

After you push your changes with BFG to a Bitbucket repo, we need to run a git gc on this repo from our side for the change in size to be reflected.

I have the following suggestions:

1. I see that you are running the BFG in a regular clone of the repo. Please run it on a mirror clone as per the instructions on the BFG page https://rtyley.github.io/bfg-repo-cleaner/

You can take a mirror clone with

git clone --mirror git@bitbucket.org:workspace-id/repo.git

2. After you follow the steps on the mirror clone, create an empty Bitbucket Cloud repo (no .gitignore, no README). Push to this empty repo, and then inspect the size and if the repo is in good shape.

If it is, then push to the repo your team normally uses.

3. Afterwards, please post a message here so I can run a git gc on the repo (not the new one, the one your team normally uses)

Kind regards,
Theodora

Ahmad Kabeer Shaukat March 18, 2024

@Theodora Boudale available for guidance?

 

Ahmad Kabeer Shaukat March 18, 2024

@Theodora Boudale  removed all the branches 
deleted all commit history using the below set of instructions  

git checkout --orphan last
git add -A git commit -am "fresh init"
git branch -D dev
git branch -m dev
git push -f origin dev


but still repo size has increased 

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 18, 2024

Hi @Ahmad Kabeer Shaukat ,

I can run a git gc for the repo, this may help reduce its size.

Which is the repo where you pushed these changes? Is it the one named v*****ces or the one named v****ces-fork?

Kind regards,
Theodora

Ahmad Kabeer Shaukat March 18, 2024

Yes please run GC on v*****ces
not v****ces-fork

Ahmad Kabeer Shaukat March 18, 2024
Ahmad Kabeer Shaukat March 18, 2024

@Theodora Boudale leave a comment after you run GC ...so that I could check

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 18, 2024

Hi @Ahmad Kabeer Shaukat,

I ran a git gc, but the repo's size remains is still 2.2 GB.

I would like to ask if you could check the following:

Take a mirror clone of the repo with the command

git clone --mirror <repo_url>

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

git count-objects -Hv

What is the output that you see?

If the sum of the fields size and size-pack in the output is less than 2.2 GB, then it is possible that some of the old references are still part of certain PRs in the repo.

Please let me know what output you see and I can then inform my colleague who is handling your support ticket to investigate.

Kind regards,
Theodora

Ahmad Kabeer Shaukat March 18, 2024

@Theodora Boudale ok I will check that
secondly the repo size in the bitbucket page is showing 2.15 which initially was when I started to solve the issue 
but I want to let you now that 
all branches have been deleted except dev which is forcibly pushed by creating an orphan branch to remove or clean all previous commit history hence no PRS exists on repo 

Ahmad Kabeer Shaukat March 18, 2024

Screenshot 2024-03-18 at 2.56.15 PM.png

Ahmad Kabeer Shaukat March 18, 2024
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 18, 2024

Thank you for the info, @Ahmad Kabeer Shaukat.

Even if you deleted all branches, some refs may still exist in older PRs of the repo.

I have informed my colleague who is handling your support ticket that the size of the mirror clone is smaller, and he is going to check if it is PR refs that take up so much space.

You will receive an update from my colleague in the support ticket you created.

Kind regards,
Theodora

Like Sabine Mayer likes this
Ahmad Kabeer Shaukat March 18, 2024

@Theodora Boudale Thanks

 

Like # people like this
Ahmad Kabeer Shaukat March 18, 2024

@Theodora Boudale creating and deleting a branch will automatically run GC behind the scenes 
am I correct ?

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 19, 2024

Hi @Ahmad Kabeer Shaukat ,

Every push to a repo will trigger a git gc but with different options and arguments depending on several conditions.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events