Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a relatively simple way to produce the history graph of a git repository in LaTeX? I'm looking for something nicer-looking than the verbatim output of git log --graph --oneline.

share|improve this question
Not a graphical solution but is something like latex-git-log sufficient? –  Alexander Jul 24 '13 at 10:49
It I am not mistaken, latex-git-log just tabulates the history. Not exactly what I am looking for. –  xvtk Jul 24 '13 at 18:50

1 Answer 1

I have begun an attempt at an answer here. It would involve piping the output of $ git log --graph --oneline to a text file and having LaTeX parse that for information. We'd need to determine the nest level of the asterisk (branch level), which is what I'm not sure how to accomplish.

Here is a MWE using a section of the tree from one of my projects:

% gitgraph.txt contains raw output of: $ git log --graph --oneline
* d764b48 added plaintext version in markdown
* 54ba4b2 release 2014-01-25
*   c589395 Merge branch 'master'
| * 9f9c652 Remove holdover from kjh gh-pages branch
* | b3bd158 exclude font files
* 63268c1 micro-typography

\newcommand\commit[2]{\node[commit] (#1) {}; \node[clabel] at (#1) {\texttt{#1}: #2};}
\newcommand\ghost[1]{\coordinate (#1);}
\newcommand\connect[2]{\path (#1) to[out=90,in=-90] (#2);}

\tikzstyle{commit}=[draw,circle,fill=white,inner sep=0pt,minimum size=5pt]
\tikzstyle{clabel}=[right,outer sep=1em]
\tikzstyle{every path}=[draw]
\matrix [column sep={1em,between origins},row sep=\lineskip]
\commit{d764b48}{added plaintext version in markdown} & \\
\commit{54ba4b2}{release 2014-01-25} & \\
\commit{c589395}{Merge branch `master'} & \\
 & \commit{9f9c652}{Remove holdover from kjh gh-pages branch} \\
\commit{b3bd158}{exclude font files} & \ghost{branch1} \\
\commit{63268c1}{micro-typography} & \\

Which produces the output: example output

This could be easily stylized in whatever way you wish. Of course the main issue is going to be finding a solution to parse the commit tree. Maybe pgfplotstable could be used?

share|improve this answer
This looks very nice! As you pointed out, the trick is going to be parsing the git output. –  xvtk Jan 30 at 12:23
Man, this looks sweet. It just lacks automation. Have you considered writing a package to generate the tikz code based on the git log? I sure would be interested in such a package, and I'm sure others would too. –  Jubobs Jan 30 at 15:45
@Jubobs, I've looked into this and I think this is the best route. One could write a hook to write this tree ($ git log --graph --oneline --all) or a pre-parsed version of it into a file to be read/processed by TeX/TikZ. This is the approach used by the gitinfo package. –  Paul Gessler Jan 30 at 15:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.