Adding Git Revision Number to LaTeX

Emrah Er bio photo By Emrah Er

I was looking for a way to include the Git revision numbers to my $\rm \LaTeX$ files and found Brent Longborough’s gitinfo package which is available on CTAN. Here’s the definition from README;

The gitinfo package provides to allow version control metadata to be incorporated into documents. The metadata is obtained from the git distributed version control system.

I followed the setup steps explained in the documentation but faced a problem during the setup. I realized that in order to succesfully create the gitHeadinfo.gin, the files created in the hooks folder must be executables.

The steps I followed are as follows:

  • I added the gitinfo package using Tex Live.
  • I copied the file post-xxx-sample.txt as post-checkout, post-commit and post-merge into the git hooks directory in my working folder.
  • Since I have more than one folder in my working directory (gitinfotest) I edited the files by adding prefixes=”folder1 folder2” and deleting prefixes=”.”. This is how my working folder looks like;


  • I made the files executables by running chmod 755 post-checkout, etc. This is how hooks folder looks like;


You can find detailed package information and commands in the documentation,