tags:

views:

787

answers:

3

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, etc) as it runs, but I don't want those to be tracked.

I'm aware that I could (maybe should) make it so all those files are put in an separate subfolder in the project, since I could then just ignore the folder.

However, is there any feasible way to keep the output files in the root of the project tree and use .gitignore to ignore everything except the files I'm tracking with Git? Something like

# Ignore everything
*

# But not these files...
script.pl
template.latex
# etc...

Thanks!

+12  A: 
# ignore these
*
# except foo
!foo
Suvesh Pratapa
+17  A: 

'An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources. ', so:

# Ignore everything
*

# But not these files...
!script.pl
!template.latex
# etc...

maybe?

Joakim Elofsson
+4  A: 

You can use git config status.showUntrackedFiles no and all untracked files will be hidden from you. See man git-config for details.

Robert Munteanu