mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
71.14k stars 6.41k forks source link

Add `switch` as alias of `checkout` to gitGraph Syntax #5422

Closed jaschop-1k5o closed 5 months ago

jaschop-1k5o commented 6 months ago

Proposal

In the gitGraph diagram, switch should be usable besides checkout to switch branches.

I teach and design workshop material for git beginners. The git switch command is much more beginner friendlly than git checkout and we teach this method first to beginners. Being able to use switch in gitGraph diagrams would reduce confusion when using them to teach git to beginners.

(You may well know, that the git checkout command is much more powerful than git switch and can e.g. checkout arbitrary commits. This is currently not implemented in gitGraph, and checkout seems to function analogous to the git switch command.)

Example

Instead of...

gitGraph
  commit
  branch feature
  commit
  checkout main
  commit
  merge feature

...I would prefer to use...

gitGraph
  commit
  branch feature
  commit
  switch main
  commit
  merge feature

...to produce this diagram.

Screenshots

image