tags:

views:

46

answers:

2

I have a few repos (for websites) that are growing very large due to the fact that images constantly change.

Is there a way to remove old data from git in order to reduce the size of the repo?

+4  A: 

git filter-branch can do this, but I'd strongly urge you to actually think more deeply about your workflow before plowing ahead with this now and planning to repeat it again in 6 months.

Novelocrat
Thanks, but from what I am reading, it seems to only go one commit at a time. I was hoping for something that removes everything up to a specific commit, leaving intact the latest version of each file.
Tony
I realize that with some low-level hacking (cf `git help commit-tree`, I think), you can actually create a new 'initial' commit that refers to some particular tree, but does not reference a parent commit. You can then create a branch at that commit, and delete all your other branches. A new clone of that repository, or a `git gc --prune` should then dump all the old history. A word of warning: keep a backup of your old repository somewhere.
Novelocrat
+2  A: 

Since you didn't specify whether you are already doing this, the documentation states that you should run git gc occasionally:

Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance.

Obviously this won't trash your history, but it should drop the repo size a bit if you haven't been running it. Don't be afraid to throw the --aggressive option in there either.

Mark Rushakoff
No, I haven't done this. This will help a bit, I just have to figure out how to do it on the XXX.git/ directories under gitosis as that is where I am running low on space.
Tony