How big is a Git commit?
This article explains how Git stores data as compressed objects and provides experimental data on how file size and directory structure affect commit size. It concludes that Git is highly efficient at managing storage through zlib compression and packfiles.
Why it matters
Understanding Git internals helps developers optimize repository management and storage usage in large-scale software projects.
Short answer: It depends. Git stores "objects" as zlib compressed data. So the exact size of a commit will depend on the compressibility of your files (which is basically a function of the amount of repetition in them).
The other factor is that Git eventually turns object files into even more efficient packfiles, saving additional space by getting rid of redundancy across objects.
https://git-scm.com/book/en/v2/Git-Internals-Packfiles
For fun, I did some little experiments (all "loose objects" with no packfiles created). Here’s the results:
17,145 bytes - committing 3 bytes of change to a file in a directory of 50 files
8,709 bytes - committing 3 bytes of change to a single-file repo
297,873 bytes - committing a 583,840 byte binary file
1,622,188 bytes - committing a huge 16,415,223 byte source file
Get smarter about the news
Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.
Create free accountAlready have an account? Sign in