Core Git 2/8

DAG History Graph

Git history is a directed acyclic graph (DAG). Each commit has its own hash and stores references to a tree snapshot plus parent commit(s), always pointing backward.

Back to Git Concepts overview

The DAG - Your Project's Family Tree

Parallel work creates diverging history. The merge commit has two parent pointers.

commit0 commit1 commit2 commit3 branch2 branch1 merge commit0 commit1 commit2 commit3 branch2 merge branch1 Two parents!
git log --oneline --decorate --graph --all

D Stands For Directed

In a Git DAG, the D means directed: every arrow has a direction and points from a commit to older ancestor commit(s). The family tree view shows the same idea in a more familiar way.

Git DAG Family Tree = C4 C2 C3 C1 Grandpa Dad Mom You Commits = People Arrows = Ancestry Same structure, different context

A Stands For Acyclic

In a Git DAG, the A means acyclic: commit ancestry cannot loop back on itself. In the diagram, `C3 -> C2 -> C1` is valid, but `C3 -> C1` coming back around to create a cycle is not allowed.

C1 C2 C3 C3 -> C1 ? Commit ancestry moves backward only. It never forms a loop.

G Stands For Graph

In a Git DAG, the G means graph: commits are nodes, and parent relationships are edges connecting them. This is the same visual structure as the family-tree example above, just applied to Git history instead of people.

src/ index.ts utils.ts package.json src/ index.ts utils.ts package.json src/ index.ts utils.ts package.json src/ index.ts utils.ts package.json src/ index.ts utils.ts package.json src/ index.ts utils.ts package.json src/ index.ts utils.ts package.json a9f4c12 b7d1e40 c3ab982 d8f2a55 e1c7b39 m9a4f0e f4b8c21 commit0 commit1 commit2 commit3 branch2 merge branch1 Two parents!
Previous Git + Commits All Concepts Back To Overview Next Branches