12

I would like to make a workflow diagram like this:

enter image description here

I found TikZ, but the sequence diagram example seems a bit obscure…

2
  • 1
    There is a tikz-uml package available that supports sequence diagrams. However, the site seems to be down at the moment. Under normal circumstances you can find it at ensta-paristech.fr/~kielbasi/tikzuml/…
    – JoG
    Commented Sep 5, 2012 at 20:35
  • @JoG, interesting. Unfortunately the link seems to be outdated.
    – MS-SPO
    Commented Jul 14, 2021 at 16:00

2 Answers 2

12

You can use this as a starting point:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes}

\begin{document}

\begin{tikzpicture}[head/.style={line width=2pt,draw=gray,rounded corners=8pt,text width=2cm,align=center}]
\node[head,fill=green!60!black!50] (wd) {working directory};
\node[head,fill=yellow!40,right=of wd] (sa) {staging \\ area};
\node[head,fill=blue!40,right=of sa] (lr) {local \\ repo};
\node[head,fill=red!40,right=2cm of lr] (rr) {remote \\ repo};
\begin{scope}[line width=2pt,gray]
\foreach \x in {wd,sa,lr,rr}
  \draw ([yshift=-5pt]\x.south) -- +(0,-7cm);
\end{scope}
\begin{scope}[every node/.style={single arrow, draw=none,fill=red!50,anchor=west,align=center}]
\node [anchor=west,text width=2.8cm] at ([yshift=-1cm]wd.south) {git add};
\node [anchor=west,text width=2.8cm] at ([yshift=-2cm]sa.south) {git commit};
\node [anchor=west,text width=3.8cm] at ([yshift=-3cm]lr.south) {git push};
\node [anchor=east,text width=3.8cm,shape border rotate=180] at ([yshift=-4cm]rr.south) {git fetch};
\node [anchor=east,text width=6.1cm,shape border rotate=180] at ([yshift=-5cm]lr.south) {git checkout};
\node [anchor=east,text width=6.1cm,shape border rotate=180] at ([yshift=-6cm]lr.south) {git merge};
\end{scope}
\end{tikzpicture}
\end{document}

A full git workflow

3
  • 1
    That's more of a finish as far as I can see :)
    – percusse
    Commented Sep 5, 2012 at 20:39
  • +1 Two questions: Where are the shadows? Are you sure that git push goes in two opposite directions? :) Commented Sep 5, 2012 at 22:29
  • @PaulGaborit hehe! I missed the "git fetch" label. I'll correct it later (and perhaps I'll add the shadows). Commented Sep 5, 2012 at 22:38
11

Almost later, but this in someway addresses the background (to be honest I played too much around arrows and colors :)).

\documentclass[svgnames]{article}

\usepackage{tikz}
\usetikzlibrary{calc,fadings,shapes.arrows,shadows,backgrounds, positioning}

\tikzset{bubble/.style={rectangle, draw=gray,rounded corners,fill=#1,align = flush center,minimum height=1cm,minimum width=1.75cm}}

\tikzfading [name=arrowfading, top color=transparent!0, bottom color=transparent!95]
\tikzset{arrowfill/.style={top color=OrangeRed!20, bottom color=Red, general shadow={fill=black, shadow yshift=-0.8ex, path fading=arrowfading}}}
\tikzset{arrowstyle/.style={draw=FireBrick,arrowfill, single arrow,minimum height=#1, single arrow,
single arrow head extend=.4cm,}}

\begin{document}

\begin{tikzpicture}
% Bubbles
\node[bubble=ForestGreen!40] (wd) at (0,0) {working\\directory};
\node[bubble=Gold!40] (sa) at (2.5,0) {staging\\area};
\node[bubble=DodgerBlue!40] (lc) at (5,0) {local repo};
\node[bubble=Tomato!40] (rc) at (8.5,0) {remote repo};

\node[above= 1 cm of rc,font={\bf}]{Remote};
\node[above= 1 cm of sa,font={\bf}]{Local};
% Lines
\foreach \bubble in {wd,sa,lc,rc}
\draw[ultra thick, gray] ($(\bubble.south)-(0,0.25)$)--($(\bubble.south)-(0,9)$);

% Arrows
\node [arrowstyle=2.5cm,xshift=-0.1cm,yshift=-1.5cm] at ($(wd.south)!0.5!(sa.south)$) {git add};
\node [arrowstyle=2.5cm,xshift=-0.1cm,yshift=-2.5cm] at ($(sa.south)!0.5!(lc.south)$) {git commit};
\node [arrowstyle=3.5cm,xshift=-0.1cm,yshift=-3.5cm] at ($(lc.south)!0.5!(rc.south)$) {git push};
\node [arrowstyle=3.5cm,xshift=0.1cm,yshift=-5cm,shape border rotate=180] at ($(rc.south)!0.5!(lc.south)$) {git fetch};
\node [arrowstyle=5cm,xshift=0.1cm,yshift=-6.5cm,shape border rotate=180] at ($(lc.south)!0.5!(wd.south)$) {git checkout};
\node [arrowstyle=5cm,xshift=0.1cm,yshift=-8cm,shape border rotate=180] at ($(lc.south)!0.5!(wd.south)$) {git merge};

% Background
\begin{pgfonlayer}{background}
\fill[gray!10]($(lc.north)!0.5!(rc.north)+(0,0.5)$)rectangle($(lc.south)!0.5!(rc.south)+(4,-9.5)$) ;
\draw[dashed, shorten <=-1.5cm] ($(lc.south)!0.5!(rc.south)$)--($(lc.south)!0.5!(rc.south)-(0,9.5)$);
\end{pgfonlayer}
\end{tikzpicture}


\end{document}

Result:

enter image description here


Another possibility to draw this kind of pictures is to exploit the pgfgantt package.

2
  • If you anchor your nodes from west or east you don't need to add the computations and can place them via below= 2cm of ....
    – percusse
    Commented Sep 5, 2012 at 22:34
  • Yes, that would have been simple, but consider that when I started placing arrows I already saw @Gonzalo answer (and noticed that I incidentally copied his error with labels). That's why I tried to differentiate my answer using calc a bit since he already positioned arrows with anchors ;). Commented Sep 6, 2012 at 8:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .