From: Andreas Ericsson Date: Mon, 08 Oct 2007 09:27:33 GMT Subject: Re: Trying to use git-filter-branch to compress history by removing large, obsolete binary files Message-ID: <4709F805.8050704@op5.se> In-Reply-To: <20071008010648.GB29433@potapov> Dmitry Potapov wrote: > On Sun, Oct 07, 2007 at 06:22:28PM -0600, Elijah Newren wrote: >> git-filter-branch --tree-filter 'rm -f testme.txt' HEAD >> git reset --hard >> rm -rf .git/refs/original/ >> vi .git/packed-refs >> # Use vi to remove the line referring to refs/original... >> git reflog expire --all --expire-unreachable=0 >> git gc --prune >> >> Seems like a wrapper is needed. :-) > > Actually, I would rather not, because you rarely need to remove anything > immediately, and 30 days delay is reasonable time to give you a chance > to recover that you removed accidentally. You can reduce it by setting > appropriate value for gc.reflogExpireUnreachable in your configuration. > The only thing you need to do is to remove .git/refs/original/heads/something > after you are sure that git-filter-branch did exactly what you wanted. > >>> Warning: all unreachable references will be removed! >> What other scenarios could lead to unreachable references? > > Any re-writing of history leads to that. > git-rebase being the most common culprit, right alongside 'git commit --amend'. >> I don't >> know how to determine whether this is safe or not (except that these >> were test repositories anyway, so I don't care what happens to them). > > Git logs all your action, so even re-writing history would not be > so disastrous if you suddenly realized that you did something wrong. > The history is stored for 30 days by default. Usually, you do not > need to mess with Git internals like you did above. Your useless > files still will disappear after being unreachable for 30 days. > > OTOH, if you want to have a clean repository immediately, I believe > 'git clone' is a better option. After you made a local clone using > it, 'git gc' should remove old garbage. > A clone only fetches revs reachable from a ref, so pruning immediately after a clone is completely pointless. -- Andreas Ericsson andreas.ericsson@op5.se OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231