How much space does a Git commit actually take up?

November 16, 2026 3 answers
Asked by QAVRIN-7x

Does Git store a full copy of every file with each commit, or just the changes? How can I tell how much space a commit uses?

Answers

Mavrik-8t

A commit represents a snapshot, but Git does not make a separate full copy of every unchanged file for it. The commit object points to a tree, which describes the files and directories in that snapshot. File contents live in blob objects, and unchanged content can be reused across commits.

The commit object itself holds metadata such as the tree ID, parent commit ID or IDs, author, committer, and message. It is often only a few hundred bytes, though a long message or other metadata can make it larger. New or changed file contents and tree objects can add more storage.

7m!corkwinder_582:

So a snapshot describes the whole project, but that does not mean all its contents are duplicated for every commit.

Reply to this answer
p.618~gasketspool

For a quick check, run git cat-file -s HEAD. That gives the uncompressed size in bytes of the current commit object, not the size of the files in its snapshot. Run git count-objects -vH for a broader view of storage used by the repository's object database.

There is no single obvious number for the disk space attributable to one commit. Objects can be shared, compressed, or stored together in packfiles, sometimes using deltas against other objects.

Reply to this answer
c.917~parcelwhisk

Watch out for what your disk usage tool is measuring. A small loose object file can occupy more disk space than its actual byte count because the filesystem allocates space in blocks. Once objects are packed together, that loose-file overhead changes too.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions