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
- Commands:
commit,branch name,checkout name,merge name,cherry-pick id: "x". - Label commits:
commit id: "fix" tag: "v1.0". - Commit types:
type: HIGHLIGHTorREVERSE.
How to use it
- Open the example in the editor, or paste your own Mermaid code.
- Edit the code on the left. The preview updates as you type, and errors point to the line.
- Export SVG or PNG, copy a Markdown block for GitHub or Notion, or copy a share link.