Skip to content
Objects

Your first commit

A commit is a snapshot of everything, not a list of changes.

People describe a commit as a set of changes. It is not. A commit points at a tree, and that tree describes every tracked file at that moment. The diff you see in `git show` is computed by comparing the commit with its parent — it is a view, not what was stored.

That is why checking out an old commit is fast and exact: git is not replaying anything, it is reading a snapshot.

`git cat-file -p HEAD` prints a commit exactly as it is stored. It is four short lines and a message, and reading one is the quickest cure for most confusion about git.

Commands in this lesson

git add
Copy the current contents of a file into the index
git commit
Record the index as a new commit on the current branch
git cat-file
Print an object's type, size or contents exactly as stored
No account, no backend. Everything you do stays in this browser.liter8.sh