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

This widget could not be displayed.

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 Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,237 views 8 11
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