I understand that a .gitignore file cloaks specified files from Git\'s version control. I have a project (LaTeX) that generates lots of extra files (.auth, .dvi, .pdf, logs,
I also had some issues with the negation of single files. I was able to commit them, but my IDE (IntelliJ) always complained about ignored files, which are tracked.
git ls-files -i --exclude-from .gitignore
Displayed the two files, which I've excluded this way:
public/
!public/typo3conf/LocalConfiguration.php
!public/typo3conf/PackageStates.php
In the end, this worked for me:
public/*
!public/typo3conf/
public/typo3conf/*
!public/typo3conf/LocalConfiguration.php
!public/typo3conf/PackageStates.php
The key was the negation of the folder typo3conf/
first.
Also, it seems that the order of the statements doesn't matter. Instead, you need to explicitly negate all subfolders, before you can negate single files in it.
The folder !public/typo3conf/
and the folder contents public/typo3conf/*
are two different things for .gitignore.
Great thread! This issue bothered me for a while ;)