Re: Unable to shrink repository size
- From
Jeff King <peff@peff.net>
- Date
- Mar 6, 2014, 15:25 UTC
- Message-ID
- <20140306152550.GA18519@sigill.intra.peff.net>
- In-Reply-To
- <CAHd499AW6nev81iVVhuoYfT0us28SSBDwbHCBa3teYB=cJR99g@mail.gmail.com>
On Wed, Mar 05, 2014 at 08:55:30PM -0600, Robert Dailey wrote:
Show 7 quoted lines
> What I'd like to do is somehow hunt down the largest commit (*not* > blob) in the entire history of the repository to hopefully find out > where huge directories have been checked in. > > I can't do a search for largest file (which most google results seem > to show to do) since the culprit is really thousands of unnecessary > files checked into a single subdirectory somewhere in history.
Other people have offered scripts to look at commit sizes. But it might also be useful to see sizes by subdirectory. Sort of a "du" across all of history. Script is below.
Note that this script also uses cat-file's "%(objectsize:disk)". So it is finding the actual on-disk storage, taking into account delta storage. You will need git v1.8.5 or later to use this feature.
git rev-list --objects --all |
git cat-file --batch-check="%(objectsize:disk) %(rest)" |
perl -lne '
my ($size, $path) = split / /, $_, 2;
next unless defined $path; # commit obj
do {
$sizes{$path} += $size;
} while ($path =~ s{/[^/]+$}{}); END { print "$sizes{$_} $_" for (keys %sizes) }
' |
sort -rn-Peff