After deleting branches storage didnt reduce

peeyushsinghal94 February 17, 2025

I deleted multiple branches, but the repository size hasn’t decreased. How can I reduce the size of the repository? Can someone suggest a solution? It's urgent.

2 answers

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

Hi @peeyushsinghal94 and welcome to the community!

If the branches you deleted have already been merged to another branch that hasn't been deleted, then the branch deletion won't make a difference to the repo's size.

However, if you deleted branches that haven't been merged to another branch yet, a garbage collection should run to remove any dangling commits that were previously accessible from this branch. Then, you may see a difference in size, but that depends also on the the size of the dangling commits that get removed.

A garbage collection runs on every push but with different parameters depending on many different conditions. If you want, I can run a garbage collection on your repo manually that should optimize the repo better. I'd need to know the first two letters of the repo name and the first two letters of the workspace ID it belongs to, or any other combination of letters that will help me identify it among the ones you have access to. Please feel free to let me know if you'd like me to do that.

In case you version any large files on other branches that you don't want to/can't delete, you may want to consider either removing them from the repo's history completely, or tracking them with Git LFS. You can check this reply of mine to another question that has more details on how to identify large files and the two options (removing them or tracking them with Git LFS):

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

Kind regards,
Theodora

peeyushsinghal94 February 23, 2025

Hi Theodora Boudale, Yes please run garbage collections from your side. My workspace id's first 2 letters are "as" and my repo's first 2 letters are "ve". on my local repo size is very less but on remote it is 706 MB. 

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

Hi @peeyushsinghal94,

Sure, thank you for the details.

I ran a garbage collection for this repo and its size is 613.4 MB now.

Does this agree with the size of your local repo?

The most accurate way to check it is on a mirror clone of a repo (a mirror clone is a bare repo with no working directory that has all remote branches):

1. Take a mirror clone with the command

git clone --mirror <repo_url>

2. Navigate to the directory of the mirror clone and run the command

git count-objects -Hv

What output do you get from this command?

Kind regards,
Theodora

peeyushsinghal94 February 24, 2025

Hi @Theodora Boudale I have checked getting exact same 613.4 MB. But i have code of around 100 MB but still repo size is 613.4 MB. I want to reduce it. How can i do that ? 

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

Hi @peeyushsinghal94,

The size of the repo doesn't depend only on the size of the files but also on the size of the diffs and other metadata for each commit of the repo.

Reducing the repo's size can be achieved by removing certain files from the history. You can check this reply of mine that I posted in an earlier message as well:

The first step is identifying the largest files that exist in the repo's history (in the link above, the first step has a command you can run to find out). If you don't need to version the largest files, you can rewrite history to remove them and consider storing them in an external server. If you do need to version them, you can migrate them to Git LFS so that they are not stored in the core Git repo. I explain both options in the link I provided. Please take a look and feel free to let me know if you have any questions.

Kind regards,
Theodora

1 vote
Brant Schroeder
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 18, 2025

@peeyushsinghal94 welcome to the Atlassian community

Take a look at this: https://community.atlassian.com/t5/Bitbucket-questions/Is-deleting-recreating-a-branch-easiest-way-to-remove-large/qaq-p/2286337 

"Branches are just pointers to different parts of the history and removing a branch will have no effect on the size of the repository, since the history of the large files is still in it. The only way to remove large files from the history is to clear the history out. You can read more about in this KB."

Suggest an answer

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

Atlassian Community Events