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.
-
8Cons: 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 08 '13 at 00:57
-
2The only benefit I can see is if for some reason, you've edited one of these auxiliary files manually. – Xavier May 08 '13 at 04:09
-
Related question: http://tex.stackexchange.com/q/17845/86 – Andrew Stacey May 08 '13 at 08:51
2 Answers
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
*.aux
*.dep
*.fdb_latexmk
*.log
*.out
*.synctex.gz
*.log
*.fls
(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.
- 44,937
- 14
- 131
- 195
-
5Worth 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. – Andrew Stacey May 08 '13 at 08:54
-
@AndrewStacey: You're absolutely right. With the benefit of some sleep I was able to expound from my original answer. – Matthew Leingang May 08 '13 at 11:45
-
2Regarding the
.gitignore: GitHub has an exhaustive template for a suitable ignore file for TeX related stuff: https://github.com/github/gitignore/blob/master/TeX.gitignore – Habi Dec 17 '14 at 09:57 -
Good link.
pgfplotsalso 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)
- 161
-
-
1there 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