gitGraphv0.9.4

什么是Git 图?

分支、合并、Tag——和你仓库一致。

gitGraphmainfeat/i18nfeat/seo
何时使用

Use a Git 图 when…

01

Branching strategy explainers

02

Onboarding new contributors

03

Documenting a release process

语法基础

The minimal syntax

Copy this and you have a working git 图. Build from here.

gitgraph.mmd
gitGraph
    commit
    commit
    branch feat/i18n
    commit
    commit
    checkout main
    merge feat/i18n
    branch feat/seo
    commit
    commit
    checkout main
    merge feat/seo
mainfeat/i18nfeat/seo
常见写法

Patterns worth memorizing

Tags

`commit tag: "v1.0.0"` adds a label to a commit dot.

Cherry-pick

`cherry-pick id: "<hash>"` reproduces a commit on the current branch.

showCommitId

Set `showCommitId: false` in init to hide the auto-generated short SHAs.

常见坑点

The things that will trip you up

Mermaid silently ignores misspellings — these are the failures we see most.

  1. 01

    Branch order in the legend follows declaration order, not visual order.

  2. 02

    You must `checkout` before committing on a branch — there is no implicit current branch.

  3. 03

    Mainline rebase isn't modeled; document linear history with `commit` instead.