For a recent project, we wanted to auto-generate our Git commit logs for inclusion in our final paper. Getting the pretty git log on the command line is easy:

git log --reverse --pretty --date=short

Converting this into the LaTeX friendly output we wanted, however, is not.

what i got

Yes, there are packages that remediate this problem, somewhat. latex-git-log is nice, but we didn’t want landscape pages, or all the excess info they include in their output. gitinfo2 is even more robust, but seemed a bit overcomplicated for our use case. If our commit log can be generated by a simple script, why can’t a TeX file with our commit log be generated by a simple script also?

Well, thanks to gitlog2latex, now it can!

Essentially, we escape LaTeX’s special characters using pandoc, then a few iterations of sed and awk to clean up the output and convert it into tables.

To use gitlog2latex, you want to grab it from github, move it into the directory you want to generate a log for, and run:

curl -O
chmod a+x
mv [mydirectory]
cd [mydirectory]

The file will be produced as gitlog.tex. If you want to name it something else, change the OUTPUT variable at the top of the script.

For gitlog2latex to work, you need to have pandoc and the tabu package for LaTeX installed. Happy TeXing!