Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to clean down a repo - reset completelty

simon July 4, 2025

Afternoon, I'm trying to find a way where by i purge all history/files/ref/tags etc form a bitbucket repo so that for all purpose it has nothing in ..
im using this snippet 

echo "Deleting existing refs (branches, tags, remotes)…";
git for-each-ref --format='%(refname)' | xargs -r -n 1 git update-ref -d;

echo "Creating empty root commit on main";
git symbolic-ref HEAD "refs/heads/main";
git commit --allow-empty -m "Initial empty commit after history reset";

echo "Running aggressive Git GC";
git reflog expire --expire=now --all;
git gc --aggressive --prune=now;
git push -u origin main --force;

this does fine at removing all the ref,files etc.. however when i look at the project reposostries view https://bitbucket.org/<user>/workspace/projects/<abc>
it shows the project to still have a size of 15mb i thought it should go back the the inital repo size of about 50kb
 

Is it even possible to do this with out a support call..

1 answer

0 votes
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 6, 2025

Hey @simon 

If you purge the repository's history, we need to manually run garbage collection. If you require assistance with GC, please feel free to raise a support ticket.

That said, I am curious why you need to reset the repository; wouldn't deleting and recreating it be much faster?

Regards,
Syahrul

 

simon July 7, 2025

hi @Syahrul  is there a better way to do the repo clean up/out? besides dropping and recreating the repo? I'm using the free tier and some times my repos get big for a short period of time before i reliase and clean them up . 

Seems odd that even tho the repo/hirstory is empty that there is still x amount showing on the repo list..

 

Regards

Simon

Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 7, 2025

Hi Simon,

There's no easier way to reset a repository than deleting it and creating a new one.

A small repository size can mean many things after you reset it, but this is typical with git. When you add or remove files, it creates dangling commits, blobs, and cache fragments that need manual garbage collection to clean up. Only Support can trigger GC manually. If you're on the free plan, please tell us your repo name, and we'll trigger it for you in the community.

Regards,
Syahrul

 

Suggest an answer

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

Atlassian Community Events