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.
The files that you are talking about (
.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.