In a Git repository, where do your files live?

Git stores files in the .git/objects directory. Each file in your repository, including every previous version, is stored in .git/objects. This storage strategy is known as “content addressed storage” where the filename of an object in the database is the same as the hash of the file’s contents. Git uses zlib compression to compress the data in .git/objects. The process of finding previous versions of a file involves traversing through the commit history and looking at the different tree and blob objects in .git/objects. Git log uses this tree traversal process to determine if a file has changed in each commit. There are over 20,000 object files in the .git/objects directory, but not all of them represent previous versions of files. Overall, Git’s storage system is efficient and allows for easy retrieval of previous versions of files.

https://jvns.ca/blog/2023/09/14/in-a-git-repository--where-do-your-files-live-/

To top