Git graphs in Confluence

A Git graph shows commits, branches and merges, so a team can agree on how code moves to a release.

Last updated

When to use it

Use a Git graph to explain a branching strategy in a contributing guide: feature branches, release branches, hotfixes, backports. You write the commands in order (commit, branch, checkout, merge) and the diagram draws the history they produce.

Example

This is the code of the Feature branch template: a branch merged back into main before a release.

gitGraph
  commit id: "Initial"
  commit id: "Set up CI"
  branch feature/search
  checkout feature/search
  commit id: "Add search API"
  commit id: "Add search UI"
  checkout main
  commit id: "Fix typo"
  merge feature/search id: "Merge search"
  commit id: "Release 1.2"

Vellnar Diagrams draws it like this:

Change a line and the diagram changes with it. Nobody needs the original drawing file, because there is none: the code is the diagram.

Add it to a Confluence page

  1. Edit a Confluence page and type /mermaid where the diagram should go.
  2. Select Mermaid diagram. The editor opens with the template list.
  3. Pick a template, or choose Start blank and paste the code above. The preview follows every keystroke.
  4. Choose Save. The diagram appears on the page.

The documentation covers the editor, the settings and the exports.

Templates

The Templates button in the editor has 5 Git graphs ready to use:

  • Feature branch: A branch merged back into main before a release.
  • Release branches: Develop, a release branch and a tagged merge into main.
  • Hotfix: A fix branched from main and merged back into develop.
  • Trunk-based development: Short-lived branches and daily deploys from main.
  • Backport: A fix made on main and cherry-picked onto a release branch.

Syntax

The code of a Git graph starts with gitGraph. The Mermaid documentation describes every element of the syntax. Vellnar Diagrams draws it with Mermaid 12.3; if a line has an error, the editor marks the line and keeps the last valid diagram on screen.

More

  • Mermaid in Confluence: how diagrams as code work in a page, and every diagram type.
  • Security: the app asks for no permissions and sends nothing outside Atlassian.