I'm using git for keeping all my sites backup here. It works very well, I can jump in and out of a expecific backup with a command.

The problem is, this is incremental. Even if I exclude a file now, it will still be there in the old revisions. This is good, but there are some big files, like sql backups, that I dont need to keep all the history.

As I backup my database everyday, in a different file name, I'm running out of space =p

How can I permanently remove old/deleted files from my git repository?

link|improve this question
feedback

2 Answers

up vote 2 down vote accepted

Use git filter-branch. An example from the manpage:

git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename' HEAD
link|improve this answer
does it take a regular expression as filename? – Tiago Scolari Nov 5 '10 at 11:49
You could use something like git filter-branch --tree-filter 'find . -regex <regex> -print0 | xargs -r0 rm' HEAD for that. (I don't like -exec ;) – al. Nov 5 '10 at 11:55
oh that worked :) It didnt free as much space as I was thinking, but its better than nothing =p – Tiago Scolari Nov 5 '10 at 14:35
If repository size is what you're after, you should go through the "Checklist for Shrinking a Repository" in the git-filter-branch manpage. – al. Nov 5 '10 at 19:40
feedback

Similar question here with a good link to an outside resource.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.