git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Duy Nguyen
Message 5 of 5 in “Unable to shrink repository size”
  1. Robert DaileyMar 6, 2014
  2. Elijah NewrenMar 6, 2014
  3. Fredrik GustafssonMar 6, 2014
  4. Duy NguyenMar 6, 2014
  5. Jeff KingMar 6, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.