How to reduce disk space usage in a large repository?
I have a git repository with about 1 year of development history, and it is already 37GB. How can I minimize the size in a way where I will delete the old history? That is, I only need the history that covers the last 2 months, others can be removed.
One Solution collect form web for “How to reduce disk space usage in a large repository?”
The three main options are:
- removing large files from the history (with, for instance, BFG)
- split a repo subfolder into its own repo
- split a repo history (starting with a new repo from HEAD of new repo, keeping the old one for archive).
On the last point, see “How do I remove the old history from a git repository?”, using a script like this one (with the SHA1 of the commit from 2 months ago, as a parameter)
#!/bin/bash git checkout --orphan temp $1 git commit -m "Truncated history" git rebase --onto temp $1 master git branch -D temp # The following 2 commands are optional - they keep your git repo in good shape. git prune --progress # delete all the objects w/o references git gc --aggressive # aggressively collect garbage; may take a lot of time on large repos
Since it rewrites the history, you will need a
git push --force.
Since the OP is pushing to
git.assembla.com (see discussion), this issue clearly states
You need to enable the
This is done from the Git repository Settings tab. You need to be an ‘Owner’ on the space to see the settings tab.