A commit is an immutable snapshot of the repository with a hash, message, author and parent, forming the unit of history.
A commit is not a diff. It is a snapshot: the complete state of every tracked file at that moment. The diff is computed on demand, by comparing the commit to its parent. That distinction matters: a commit can be checked out, signed, referenced by hash, and shared with a remote, all without reference to how it was built.
Each commit has:
- A hash (SHA-1 for older repos, SHA-256 for newer ones) that uniquely identifies it.
- A parent commit (or two, for a merge, or zero, for the first commit).
- A tree object pointing to the directory structure at that moment.
- An author (name, email, timestamp) and a committer (same shape, sometimes different).
- A message that explains why the change was made.