2

I have a Git repository which is around 2.2GB at the moment. It was originally created to hold a WordPress website and after a large redesign it now houses a much smaller HTML static site.

Because the repository still holds all of the references to the previous WordPress site, it is much larger than it needs to be which is causing some size limit issues with the provider we use.

The repository is distributed, that is there are local cloned versions of it on more than one development machine, and Git is used to integrate changes across the staging and production servers the site runs on. There is a master branch and then one branch each for staging and production changes.

I do have access or at least know where all cloned instances of the repository are so I can run updates on each of them if required.

What I'd like to do is remove the references to the earlier WordPress commits and effectively restart the repository from the redesign point.

I have searched on StackOverflow and across the web but due to the fact any actions of this nature modify the Git history, there have always been warnings against running commands like git rebase.

What would be the best way of fixing this and reducing the repository size?

Adam Taylor
  • 162
  • 8
  • You could remove the git folder, and re-initialise the repo from that point. You'd have no history, but no "old references" to bloat it. – evolutionxbox Dec 22 '17 at 13:24
  • 1
    What you want is not possible _without_ modifying history with something like `git rebase` because the hash of any commit will change if you change it's parent. Using commands like `git rebase` which modify history is fine in certain situations. You simply need to understand the implications of doing so. In this situation, it probably makes sense. – mkasberg Dec 22 '17 at 21:00
  • I'd recommend: archive the repository as it is right now. Use `git rebase` or similar to remove the history you don't care about. From that point, treat it as an entirely new Git repository, that comes with a little bit of history. – mkasberg Dec 22 '17 at 21:01

0 Answers0