Follows https://codewords.recurse.com/issues/two/git-from-the-inside-out
- Adding a file will hash its content, and add a file in the
objects
directory to track it. The object content is just a compressed version of the file contents. The first two letters of the file content become the directory that the object is stored in, and the rest of the hash is the object file name. - Each object is a full snapshot of the file content. It does not represent a diff. Because the file name and location are not stored in the blobs, two identical files will point to the same blob.
- When there are too many loose objects, git packs them into the
pack
folder that can store diffs instead of full file contents. - When commiting, git creates a snapshot of the current blobs and trees. trees are used to track directories, and point to blobs or other trees. Files are represented by blobs.
- A commit is also an
object
, that points to thetree
for the root directory: https://codewords.recurse.com/images/two/git-from-the-i