Object Files
What
Object files stored under .git/objects/ are not plain text files. To save disk space, Git uses the zlib compression algorithm to compress all objects before writing them to the disk.
How
If you try to read an object file directly using standard tools like cat, your terminal will output unreadable, corrupted characters because the file contains compressed raw bytes:
# Trying to view raw object content yields unreadable binary data
cat .git/objects/5b/a786fcc93e8092831c01e71444b9baa2228a4f
To view the raw bytes, developers use utility tools like xxd (a hex editor tool) to convert the compressed binary file into readable hexadecimal format:
# View hexadecimal format of the compressed file
xxd .git/objects/5b/a786fcc93e8092831c01e71444b9baa2228a4f
Why
By compressing every object on disk, Git dramatically reduces the physical size of the .git database. This ensures that even large, multi-year software projects with tens of thousands of commits and files can be stored efficiently in a relatively tiny amount of disk space.
Summary
Git object files are compressed with zlib compression, making them unreadable as plain text unless they are inspected with a hex editor or decompressed first.