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

Re: git repository size / compression

From
Carlos Martín Nieto <cmn@elego.de>
Date
Sep 9, 2011, 08:23 UTC
Message-ID
<1315556595.2019.11.camel@bee.lab.cmartin.tk>
In-Reply-To
<CALFxCvzVjC+u=RDkDCQp0QqPETsv8ROE8tY=37tmMWxmQoJOEw@mail.gmail.com>
On Thu, 2011-09-08 at 21:37 -0500, neubyr wrote:
Show 8 quoted lines
> I have a test git repository with just two files in it. One of the
> file in it has a set of two lines that is repeated n times.
> e.g.:
> {{{
> $ for i in {1..5}; do cat ./lexico.txt >> lexico1.txt &&  cat
> ./lexico.txt >> lexico1.txt && mv ./lexico1.txt ./lexico.txt;  done
> }}}
> 

So you've just created some data that can be compressed quite efficiently.

Show 14 quoted lines
> I ran above command few times and performed commit after each run. Now
> disk usage of this repository directory is mentioned below. The 419M
> is working directory size and 2.7M is git repository/database size.
> 
> {{{
> $ du -h -d 1 .
> 2.7M    ./.git
> 419M    .
> 
> }}}
> 
> Is it because of the compression performed by git before storing data
> (or before sending commit)??
> 

Yes. Git stores its objects (the commit, the snapshot of the files, etc.) compressed. When these objects are stored in a pack, the size can be further reduced by storing some objects as deltas which describe the difference between itself and some other object in the object-db.

Show 9 quoted lines
> Following were results with subversion:
> 
> Subversion client (redundant(?) copy exists in .svn/text-base/
> directory, hence double size in client):
> {{{
> $ du -h -d 1
> 416M    ./.svn
> 832M    .
> }}}

Subversion stores the "pristines" (which is the status of the files in the latest revision) inside the .svn directory. I wouldn't call this copy redundant, though, as it allows you to run diff locally. The pristines are stored uncompressed, which is why you half of the space is taken up by the .svn directory.

Show 10 quoted lines
> 
> Subversion repo/server:
> {{{
> $ du -h -d 1
>  12K    ./conf
> 1.2M    ./db
>  36K    ./hooks
> 8.0K    ./locks
> 1.2M    .
> }}}

I don't know how the repository is stored in Subversion, but it may also be compressed. You may be able to reduced your git repository size by (re)generating packs with 'git repack' and doing some cleanups with 'git gc', but the repository size is not often a concern.

   cmn
Previous: neubyrNext: neubyr
Message 2 of 10 in “git repository size / compression”
  1. neubyrSep 9, 2011
  2. Carlos Martín NietoSep 9, 2011
  3. neubyrSep 9, 2011
  4. Sverre RabbelierSep 9, 2011
  5. Carlos Martín NietoSep 9, 2011
  6. neubyrSep 9, 2011
  7. Jakub NarebskiSep 9, 2011
  8. neubyrSep 9, 2011
  9. John SzakmeisterSep 9, 2011
  10. Andreas KreySep 9, 2011

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.