# Mermaid Git Graph Cheat Sheet

A branch history, drawn.

## Commits

Every commit is a line, and the commits land on the branch you are on.

```mermaid
gitGraph
    commit
    commit
    commit
```

![A git graph on the main branch with three commits in a row.](/diagrams/gitgraph/basic.svg)

## Branching

branch starts a branch, and checkout goes back to one you were on.

```mermaid
gitGraph
    commit
    branch develop
    commit
    checkout main
    commit
```

![A git graph with a main branch of two commits and a develop branch splitting off after the first.](/diagrams/gitgraph/branches.svg)

## Merging

merge folds a branch back into the one you are on.

```mermaid
gitGraph
    commit
    branch feature
    commit
    checkout main
    merge feature
```

![A git graph where a feature branch splits off main and is merged back into it.](/diagrams/gitgraph/merge.svg)

## Tagging a commit

The tag goes after the commit keyword, in quotes.

```mermaid
gitGraph
    commit tag: "v1.0"
    commit tag: "v1.1"
```

![A git graph with two commits, the first tagged v1.0 and the second tagged v1.1.](/diagrams/gitgraph/tags.svg)

## Draw it in Mernyx.

Open a .mmd file, move a node on the canvas, and the source comes with it. Native on macOS, no browser involved.
