xxxxxxxxxx
# Ignore everything
*
# But not these files...
!.gitignore
xxxxxxxxxx
# 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/