Commits (The Glue)
The biggest misconception you will ever learn: Commits are not diffs. They do not store what "changed." A commit is just a small text file.
What is actually inside?
If you think about it, we already have all our data stored in Blobs, and all our directory structure stored in Trees. A commit acts as the glue. It literally just stores your Author Name, a Timestamp, a Commit Message, and then a pointer to the root Tree.
Commit Details (What you edit)
Raw Commit File
The Avalanche Effect
Have you ever used git commit --amend to fix a typo in your commit message? Look at the simulation above.
Try adding a single dot `.` to the end of the commit message. Notice how the giant green hash at the bottom changes completely? Because Git calculates the hash based on the raw text file, altering anything—even changing the timestamp by one second—forces exactly half of the cryptographic bits to flip.
You can't edit commits
Because altering the timestamp or message completely changes the resulting SHA-1 hash, editing commits is impossible. When you use `--amend`, Git does not edit your commit. It creates a brand new one with a brand new hash, and abandons the old one to the garbage collector.
Wait, how is the timeline built?
Look at the second line of the raw commit file: parent a1b2c3.... This is how Git builds branching history! Every commit simply points a hash backward to the commit that came before it. This creates a Directed Acyclic Graph (DAG).