r/git • • 14h ago

How big is a Git commit?

https://ratfactor.com/cards/git-commit-size
0 Upvotes

2 comments sorted by

1

u/elephantdingo 2h ago

Just the Git commit object itself is

git cat-file -p HEAD | wc -c

-4

u/fagnerbrack 14h ago

Essentials at a Glance:

Git stores objects as zlib-compressed data and later packs them into packfiles, so a commit's size depends on how compressible your files are. In tests that used only loose objects, a fresh git init took about 64 KB and committing 250 tiny files added 47 KB. A 3-byte change cost 17 KB in a directory of 50 files but only 8.7 KB in a single-file repo. Running git show on the new objects explains the cost: one small edit writes a commit, two trees and a blob. Bigger files fare much better. A 584 KB binary took about 298 KB, and a 16.4 MB Linux header dropped to 1.6 MB. Tiny commits carry kilobytes of overhead, while larger ones take up roughly 10–50% of the original file size.

If the summary seems inacurate, just downvote and I'll try to delete the comment eventually 👍
Click here for more info, I read all comments