All diagram types Open editor

merIDK / Diagram types / Git graph

Mermaid Git graph: example and syntax

Git graphs draw commits, branches and merges. Use them to explain a branching strategy such as GitFlow or trunk-based development, or a release process.

Open this example in the editor

Example code

gitGraph
    commit id: "init"
    branch develop
    checkout develop
    commit id: "api"
    branch feature/login
    commit id: "form"
    commit id: "tests"
    checkout develop
    merge feature/login
    checkout main
    merge develop tag: "v1.0"
    commit id: "hotfix"

Result

gitGraph
    commit id: "init"
    branch develop
    checkout develop
    commit id: "api"
    branch feature/login
    commit id: "form"
    commit id: "tests"
    checkout develop
    merge feature/login
    checkout main
    merge develop tag: "v1.0"
    commit id: "hotfix"

Syntax quick reference

How to use it

  1. Open the example in the editor, or paste your own Mermaid code.
  2. Edit the code on the left. The preview updates as you type, and errors point to the line.
  3. Export SVG or PNG, copy a Markdown block for GitHub or Notion, or copy a share link.

More diagram types