1

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?

1
  • Similar question here with a good link to an outside resource. Nov 14, 2010 at 23:02

1 Answer 1

3

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

git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename' HEAD
4
  • does it take a regular expression as filename? Nov 5, 2010 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, 2010 at 11:55
  • oh that worked :) It didnt free as much space as I was thinking, but its better than nothing =p Nov 5, 2010 at 14:35
  • 1
    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, 2010 at 19:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .