Mermaid diagram types

Mermaid git graphs

A Mermaid git graph draws a commit railway from commands you already know: `commit`, `branch`, `checkout`, and `merge`. It's the cleanest way to document a branching strategy without screenshotting a Git client.

A feature-branch flow with a release tag.

Git graphs are documentation diagrams, not repository visualisations — you script the ideal flow (how your team should branch and release), and the diagram stays stable as the real history grows.

When to use a git graph

  • Documenting your team's branching strategy
  • Explaining git-flow vs trunk-based development
  • Release-process documentation
  • Onboarding guides for contribution workflows

The Mermaid code

Copy it anywhere Mermaid renders — or see the full syntax reference.

gitGraph
    commit
    branch develop
    checkout develop
    commit
    branch feature/login
    checkout feature/login
    commit
    commit
    checkout develop
    merge feature/login
    checkout main
    merge develop tag: "v1.2.0"

Frequently asked questions

How do I create a git graph in Mermaid?
Start with `gitGraph` and script the history: `commit` adds a commit on the current branch, `branch <name>` creates and switches to a branch, `checkout <name>` switches back, and `merge <name>` merges it in. Add `tag: "v1.0"` to a commit or merge to mark releases.
Does a Mermaid git graph read my actual repository?
No — it renders exactly the commits and branches you write in the code block. That's intentional: branching-strategy docs should show the canonical flow, not whatever the repo history currently looks like.
Can I label commits in a git graph?
Yes. Use `commit id: "fix login"` to name a commit, `tag: "v1.2.0"` for release tags, and `type: REVERSE` or `type: HIGHLIGHT` to mark special commits visually.

Git graph templates

Other Mermaid diagram types