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.
The three main options are:
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
--force
option.
This is done from the Git repository Settings tab. You need to be an 'Owner' on the space to see the settings tab.