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,
# Ignore everything
*
# But not these files...
!script.pl
!template.latex
And probably include:
!.gitignore
From https://git-scm.com/docs/gitignore:
An optional prefix "
!
" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("\
") in front of the first "!
" for patterns that begin with a literal "!
", for example, "\!important!.txt
"....
Example to exclude everything except a specific directory
foo/bar
(note the/*
- without the slash, the wildcard would also exclude everything withinfoo/bar
):$ cat .gitignore # exclude everything except directory foo/bar /* !/foo /foo/* !/foo/bar