As question says, I am just interested to know the pros and cons of keeping track of auxiliary files of a LaTeX project in every commit of git repository.

  • 8
    Cons: assume you edit the .tex, commit, but not compile. Now your snapshot has .tex and .aux "in disagreement". Pros: can't see anything. – mbork May 8 '13 at 0:57
  • 2
    The only benefit I can see is if for some reason, you've edited one of these auxiliary files manually. – Xavier May 8 '13 at 4:09
  • Related question: tex.stackexchange.com/q/17845/86 – Loop Space May 8 '13 at 8:51

The files that you are talking about (.log, .aux., .bbl., .blg, .toc, etc.) are created by LaTeX (or BibTeX, or any other auxiliary program) “on the fly.” They are usually dependent on the source .tex file. Since there's no information in those files that's unique to them (i.e., that can't be recovered from the source .tex file) and you would never edit them manually, there's no advantage to versioning them. At best, you commit a file that can be replicated byte-for-byte from another process, which is redundant. At worst, as mbork points out, if you commit the .tex file without compiling (and producing new auxiliary files), you are committing out-of-date information.

On the contrary, I would exclude those files from version control. In git you can do this by creating a file .gitignore in the repository directory (.git). In that file put patterns of the auxiliary files you want to ignore. Here is a list that I typically use:

# TeX, snapshot, and latexmk generated files

(Habi provides a nice link to an expansive .gitignore file on github.) You can also put these patterns in the git directory within the repository .git/info/exclude. I have a git template that has such an exclude file in it, then when I want to gitify a new document I run

$ git init --template=/path/to/template

and I'm done.

You can also do this globally. See Ignoring Files from GitHub Help.

  • 5
    Worth saying why there's no advantage. The point is that LaTeX or BibTeX will generate these files whenever they are run, so there's no point in versionning them as you can always recover them from existing files. The point of putting a file under version control is to be able to restore it if you make a mistake, but as it is autogenerated it is unlikely that you are editing it itself, and as it is generated by LaTeX then you can always get it back by running latex. – Loop Space May 8 '13 at 8:54
  • @AndrewStacey: You're absolutely right. With the benefit of some sleep I was able to expound from my original answer. – Matthew Leingang May 8 '13 at 11:45
  • 2
    Regarding the .gitignore: GitHub has an exhaustive template for a suitable ignore file for TeX related stuff: github.com/github/gitignore/blob/master/TeX.gitignore – Habi Dec 17 '14 at 9:57
  • Good link. pgfplots also adds some temp files that might make good additions to that ignore file. – Matthew Leingang Dec 17 '14 at 13:37

One advantage of tracking .bbl is that you can use latexdiff to track also the changes of bibliography list. (latexdiff comes with vc support)

  • The same applies to the table of contents, to the index, etc. – giordano Dec 17 '14 at 9:54
  • 1
    there are also times when the .bbl comes in handy, e.g. to paste into .tex files for publishers who don't do bibtex. but default should be to not track these. – petrelharp May 12 '15 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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