Markdown Git graph maker
Visualise a branching Git history. Describe commits, branches and merges in Mermaid to explain a workflow or teach version control.
Mermaid Git graph syntax
A Git graph is a list of commits, branches and merges read from top to bottom. You commit on the current branch, create branches and merge them back. Here is each piece you can write.
Commits
Each commit adds a node to the current branch.
You write
gitGraph
commit
commit
commit
You get
Branches
Create a branch, switch to it with checkout, then commit on it.
You write
gitGraph
commit
branch develop
checkout develop
commit
commit
You get
Merges
Switch back to a branch and merge another into it.
You write
gitGraph
commit
branch feature
checkout feature
commit
checkout main
merge feature
You get
Labels and tags
Name a commit with id and mark a release with tag.
You write
gitGraph
commit id: "init"
branch feature
checkout feature
commit id: "work"
checkout main
merge feature tag: "v1.0"
You get
Cheat sheet
| Write this | You get |
|---|---|
gitGraph | Start a Git graph |
commit | A commit on the current branch |
commit id: "text" | A commit with a label |
branch name | Create a branch |
checkout name | Switch to a branch |
merge name | Merge a branch into the current one |
merge name tag: "v1" | Merge and tag the result |