0

I have a document in LaTeX. When I compile it, LaTeX produces a lot of auxiliary files which I would not like to store in git repository.

The folder looks like this:

-rw-r--r--. 1 user mygroup   5295 Nov  1 13:21 report.sty
-rw-r--r--. 1 user mygroup   7187 Nov  1 15:53 review.aux
-rw-r--r--. 1 user mygroup  26716 Nov  1 15:53 review.bbl
-rw-r--r--. 1 user mygroup  96804 Nov  1 15:53 review.bcf
lrwxrwxrwx. 1 user mygroup     52 Nov  1 15:57 review.bib -> ../../../../papers/libraries/zoterobibtex/review.bib
-rw-r--r--. 1 user mygroup   1068 Nov  1 15:53 review.blg
-rw-r--r--. 1 user mygroup  50626 Nov  1 15:53 review.log
-rw-r--r--. 1 user mygroup    821 Nov  1 15:53 review.out
-rw-r--r--. 1 user mygroup 360265 Nov  1 15:53 review.pdf
-rw-r--r--. 1 user mygroup   2315 Nov  1 15:53 review.run.xml
-rw-r--r--. 1 user mygroup   1472 Nov  1 13:21 review.tex

and my .gitignore is following:

# LaTeX log files
**/tex/*.log

# Emacs
**/*~
**/#*#

# ignore tex files
**/tex/review.aux
**/tex/review.bbl
**/tex/review.bcf
**/tex/review.bib
**/tex/review.blg
**/tex/review.log
**/tex/review.out
**/tex/review.run.xml

Obviously tex is my working directory! As you can see .gitignore should tell git to ignore everything apart from review.tex, review.sty and review.pdf. For some reason, git still includes review.bib when changes are made. This file is a relative soft link to another file, my library. I want to ignore it as review.bib is handled by one of my lib managers elsewhere. If everything's clean, git status gives output:

Your branch is up-to-date.
nothing to commit, working tree clean

but when I remove review.bib, just for test, git status points out review.bib is deleted, which IMO should still report working tree clean. Does git handles links differently?

Celdor
  • 2,437
  • 2
  • 23
  • 44
  • 2
    Since `git status` reports `review.bib` as deleted when you delete it, it seems `review.bib` already exists in the repository. The ignore files are used only by `git add`. After the file was committed into the repository, Git tracks its status no matter what you put in the ignore files. Use `git rm --cached review.bib` then commit to remove the file from the repo and to let the ignore rules apply for it. – axiac Nov 01 '17 at 16:28
  • OK, so it has nothing to do with soft links. I can't figure out how to get rid of this one file and the message. when I tried to delete file, stage, commit and then add the file again, git still seems to track the changes. Do you know the way how to completely remove the file from repository? – Celdor Nov 01 '17 at 16:42
  • As I said in my previous comment `git rm --cached review.bib; git commit` does the trick. The file is still in the history but not tracked any more. Removing it from the repository history is possible but in this case it is not worth it. – axiac Nov 01 '17 at 17:05
  • Sorry. I have not seen the command. Thanks for help. – Celdor Nov 01 '17 at 17:08

0 Answers0