You are here

Make .gitignore ignore everything except a few files

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.
# Ignore everything
*

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

# ...even if they are in subdirectories
!*/

code type: