1

We have a large bitbucket repo (1.89 GB) that our engineering team needs to reduce to continue to use the repo on Bitbucket cloud.

The goal is to reduce the size of the current repo by removing old commits and history.

The trick, we can not loose the commit history so we have a secondary repo, where we can move the old history or the new commits to.

Trying to figure out the best option to do this.

Option 1:

Not ideal as many users already have the current repo set up in Sourcetree

Option 2

  • Create a new repo, clone the current repo, push it to the new repo as a archived repo
  • Reduce the history of the local repo using the documentation in the above link, push it back to current remote repo

Option 3

  • Clone the repo locally, run git commands if they exist to split it into two local repo based on commit history, i.e. keep the last 4 commits only, everything else goes into a new repo
  • Push the current commits to the current remote repo
  • Push the old commits to the new repo

This option is more ideal but seems very close to option two, but wanted to see if there are git commands people are aware of to do option 3?

Govna
  • 348
  • 1
  • 4
  • 16
  • 1
    Possible duplicate of [How do I reduce the size of a bloated Git repo by non-interactively squashing all commits except for the most recent ones?](https://stackoverflow.com/questions/24153548/how-do-i-reduce-the-size-of-a-bloated-git-repo-by-non-interactively-squashing-al) – phd Apr 30 '19 at 18:29
  • https://stackoverflow.com/search?q=%5Bgit%5D+remove+old+commits+reduce+size – phd Apr 30 '19 at 18:29
  • Thanks, but that wasn't exactly what i was looking for but lead me to rethink this. Since all i need is to remove commit history, we decided to create a new temp_branch and move the code to there, removed the master branch and then rename the temp_branch to master. I dont like this solution one bit, but it reduced our repo size a good amount and our engineering team said everything was still working after cloning the code again. – Govna May 01 '19 at 17:24
  • Maybe you could just clean it up a bit? Have a look at https://rtyley.github.io/bfg-repo-cleaner/ – eeijlar May 01 '19 at 20:59
  • We did actually look at bfg-cleaner, but unfortunately there a ton, like thousands of small files vs a larger file. Removing the commit history which was 5 years worth of commits reduced our size by 4 MB and we employed zipping the folder structure which got us under 1 GB. – Govna May 03 '19 at 16:31

0 Answers0