GIT / A CONCEPT NOTE

Commits & the DAG

history as a graph

~65 sec read

Overview · mechanism
pitfall · examples

01 / THE SHORT VERSION

The idea in a few sentences.

Git tracks project history as a Directed Acyclic Graph (DAG). Commits are snapshot nodes pointing to parent commit hashes, creating a traceable history tree.

02 / FOLLOW THE MECHANISM

How commits record snapshots

  1. File modify

    user edits code files in active workspace.

  2. Git commit

    creates new commit node storing diff, timestamp, author, and parent SHA.

  3. Graph link

    new commit hash points back to previous parent commit hash.

  4. Branch head

    current branch tag (like main) updates, pointing to the new commit SHA.

04 / COMMAND NOTES

Read the command, then the result.

Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.

EXAMPLE 01 · REFERENCE

visualize the git repository history DAG in terminal

git log --graph --oneline --all

EXAMPLE 02 · REFERENCE

inspect raw git object content contents

git cat-file -p COMMIT_SHA

Explore command anatomy in the CLI lab