cheatsheet / current

Git Graph

Use Mermaid gitGraph to explain branching, merging, hotfixes, and release flow.

Git Graph

Use Mermaid gitGraph to explain branching, merging, hotfixes, and release flow.

Basic template

gitGraph
    commit
    branch feature
    checkout feature
    commit

Core syntax

  • Start with gitGraph
  • Create commits with commit
  • Create a branch with branch name
  • Switch with checkout name
  • Merge with merge branchName
  • Add labels with id: and tag:

Common example

gitGraph
    commit id: "init"
    commit id: "base"
    branch feature/reporting
    checkout feature/reporting
    commit id: "build report"
    commit id: "add export"
    checkout main
    commit id: "hotfix"
    merge feature/reporting
    commit tag: "v1.2.0"

Good for

  • Teaching Git workflows
  • Explaining release strategy
  • Showing what happened in a tricky merge

Watch for

  • This is for conceptual history, not exact repository reconstruction
  • Keep branch names short so the graph stays readable