How Git Works

Interactive commit DAG. Click commit, branch, merge and watch the graph update.

$ Created repo with initial commit on main.

What this Git visualization shows

Commit, branch, and merge on an interactive commit graph and watch the DAG (directed acyclic graph) update live. Each commit becomes a node pointing at its parent, branches appear as labels sliding along the graph, and merges join two lines of history — the mental model that makes Git finally click.

How Git actually works

Git stores snapshots, not diffs. Every commit records the full tree plus a pointer to its parent commit(s), which is why history forms a graph. A branch is just a lightweight, movable pointer to a commit; HEAD points to wherever you are now. A merge creates a new commit with two parents; a rebase instead replays your commits on top of another branch to keep history linear.

Why it matters

Most Git confusion — detached HEAD, "why did rebase do that", lost commits — dissolves once you can see the graph the commands are manipulating. Keep the syntax handy with the Git cheatsheet.

Frequently asked questions

Merge vs rebase — what's the difference?

Merge preserves history and creates a merge commit joining two branches. Rebase rewrites your commits onto another branch for a linear history. Merge for shared branches; rebase for cleaning up local work.

What is HEAD?

A pointer to your current position in the graph — usually the tip of the branch you have checked out.

What is a detached HEAD?

When HEAD points directly at a commit instead of a branch. New commits there aren't on any branch and can be lost — create a branch to keep them.