# ignore everything in current directory
/*
# !pattern now negates the "ignore everything" and keeps 'pattern'
# keep .gitignore
!.gitignore
# keep mydirectory, along with everything inside it
!mydirectory/
# Ignore everything
*
# But not these files...
!.gitignore
!script.pl
!template.latex
# etc...
# ...even if they are in subdirectories
!*/
# if the files to be tracked are in subdirectories
!*/a/b/file1.txt
!*/a/b/c/*