Git graphs: cherry-pick and revert

Git graphs: cherry-pick and revert

puml.online

简介 / Introduction

cherry-pick and revert are the two Git commands whose history is hardest to remember: the first copies a commit onto another branch, the second undoes an old commit with a new one. A branch diagram usually explains them faster than a paragraph of prose.

PlantUML’s gitgraph syntax and Mermaid’s gitGraph can both draw branch graphs, but their support for these two commands differs. This article uses one scenario — branch feature off main, cherry-pick the feature commit back onto main, then revert a commit — and shows how each engine writes it, plus the syntax differences.

PlantUML 版

PlantUML wraps the diagram in @startgitgraph / @endgitgraph, and both cherrypick and revert are native directives:

1
2
3
4
5
6
7
8
9
@startgitgraph
commit id: "Initial commit"
branch feature
checkout feature
commit id: "Experimental feature"
checkout main
cherrypick id: "Experimental feature" tag: "v1.1"
revert id: "Initial commit"
@endgitgraph

Mermaid 版

Mermaid’s gitGraph spells the pick operation cherry-pick (with a hyphen) and supports tag as well:

1
2
3
4
5
6
7
gitGraph
commit id: "Initial commit" tag: "v0.9"
branch feature
checkout feature
commit id: "Experimental feature"
checkout main
cherry-pick id: "Experimental feature" tag: "v1.1"

对比 / Side-by-side

Feature PlantUML Mermaid
Diagram container @startgitgraph / @endgitgraph gitGraph header, no closing marker
Pick a commit cherrypick id: "X" cherry-pick id: "X" (hyphenated)
Revert a commit revert id: "X" Not supported — the parser errors out
Tags tag: "v1.1" on its own line tag: "v1.1" after a commit
Delete a branch delete branch <name> Not supported
Commit types Supports type: NORMAL / REVERSE / HIGHLIGHT Supports type: NORMAL / REVERSE / HIGHLIGHT

小结 / Wrap-up

If you only need to explain “where did this commit come from” in a README, Mermaid’s cherry-pick is enough — at the cost of not being able to show a revert anywhere in the same file. To express a full history correction such as “pick, then roll back”, PlantUML’s gitgraph is clearly stronger: cherrypick, revert and delete branch are all there, and tags can sit on their own line. Both engines reference commits the same way through id, so the same history can move between them by swapping a single keyword.

  • Title: Git graphs: cherry-pick and revert
  • Author: puml.online
  • Created at : 2026-11-03 09:00:00
  • Updated at : 2026-11-26 01:07:01
  • Link: https://puml.online/blog/git-graph-cherry-pick-revert-en/
  • License: This work is licensed under CC BY-NC-SA 4.0.