Replace underlying git repo files

We have a very large repository and have gone thru the steps of trying to shrink it (using BFG to remove unneeded large files) and ran it fine against a clone repository. But when running it against an actual copy of the existing repo (file copy, not clone), it doesn't shrink as much. The common suggestion I've seen is to clone it. I'm fine with this, but here's the question. If I want to replace the Bitbucket git directory with my newly shrunken clone, which files need to remain (i.e. repository-config, config, description, hooks).

1 answer

0 votes

Hi Richard! I'm not sure if I understand your question completely, you'd like to replace your large repository by the repo you've already shrunk, is that correct?

If that's the case, is there any reason why you can't simply clone your reduced repo and remove the larger one? Or run the BFG on the actual repo you want to shrink?

Also, remember to tell us whether you're using Bitbucket Cloud or Server.



We are using Bitbucket Server.

The shrink process is as follows:


git reflog expire --expire=now --all

git repack -A -d

git clone

When run on a mirror clone of the repo, I get a repo around 600 MB. When run on a copy of the repo as a trial (we shut down BB and copied the literal files), the repack doesn't shrink it nearly as much (only down to 3 GB or so).

So I want to mirror clone the repo, run the shrink, and then replace the repo on the BB with my clone. But I imagine some of the files in that directory are more related to Bitbucket server and not part of the Git repo itself.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,945 views 7 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you