Exploring git-internals

At its core, git is a content-addressable-filesystem. This means that at the heart of git is a simple key-value data store. When you insert any kind of content into it, it returns a unique key that you can use to retrieve that content again later. This key is a sha-1-hash.

The object-database

The dot-git-directory contains a subdirectory called objects, which stores all the content for your repository. There are four main types of git-objects:

  • blob: Stores file data without the filename or metadata.
  • tree: Stores filenames and groups blob objects together, effectively representing a directory structure.
  • commit: Stores the metadata for a snapshot, including author, committer, and a pointer to the root tree.
  • tag: A persistent pointer to a specific commit.

Plumbing vs Porcelain

Users typically interact with git via porcelain-commands such as git add or git commit. However, the system is built on plumbing-commands like git hash-object and git cat-file. These tools manipulate the git-index and git-references directly. For deeper technical insights, refer to the official Git Documentation or the Index Format Specification.