---
title: "Version Control as a Graph of Commits"
description: "A repository is a graph: each commit is a snapshot that points at the one it came from, and a branch is a movable label on a node. Once the shape is clear, most version control commands stop being inc"
canonical: https://lightmysky.com/learn/computing/version-control-as-a-graph-of-commits-mt_oKsDRKirMy
source: https://lightmysky.com/learn/computing/version-control-as-a-graph-of-commits-mt_oKsDRKirMy.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Version Control as a Graph of Commits

A repository is a graph: each commit is a snapshot that points at the one it came from, and a branch is a movable label on a node. Once the shape is clear, most version control commands stop being incantations and become moves on that graph.

Subject: Computing · Area: Software Engineering · Ages 18 to 19
Page: https://lightmysky.com/learn/computing/version-control-as-a-graph-of-commits-mt_oKsDRKirMy

## Ready when they can

- Draw the commit graph of a short history and mark where each branch label sits
- Say what changes in the graph when a commit is made and when a branch is created
- Explain what a detached head means in terms of the labels

## Lesson: History as a graph of snapshots

Each commit is a snapshot that points at its parent. Those links form a graph of history. A branch is only a movable label stuck on one node, and HEAD marks which label you stand on.

Start with commit A, then B, then C, while main moves A to B to C. Create a branch named feature at C and no node is added: a second label just lands on C. Commit D on feature and only feature slides to D, while main stays on C.

**Example.** Check out an old commit directly and HEAD points at a node with no branch label. That is a detached head. New commits there grow with no label to hold them, so switching away can strand them.

**Tip.** Read every command as a graph move. Commit adds a node and slides your label, branch adds a label, checkout moves HEAD. Name the moved labels before you run anything.

**Recap.** Commits link into a graph, branches label nodes, and HEAD marks where you stand.

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [The Project Arc: Building a Program in Stages](https://lightmysky.com/learn/computing/the-project-arc-building-a-program-in-stages-mt_hACOaB3nA_)
- [Graphs and How to Store Them](https://lightmysky.com/learn/computing/graphs-and-how-to-store-them-mt_tSO-F1sTuu)

## Opens up

- [Branching, Merging and Resolving a Conflict](https://lightmysky.com/learn/computing/branching-merging-and-resolving-a-conflict-mt_l3vFbU7L3E)
- [Reproducibility in Practice: Data, Code and What Another Lab Can Rerun](https://lightmysky.com/learn/science/reproducibility-in-practice-data-code-and-what-another-lab-can-rerun-mt_QuHuEyasFt)
