Create a .gitignore
file in current directory.
touch .gitignore open .gitignore
Ignore all files under dirname/
except dirname/filename.txt
dirname/* !dirname/filename.txt dirname/*/bin/config
You have to list the directory you want to exclude as <dirname>/*
and not <dirname>/
because the latter will reference the directory as a whole, not it's contents so the !
inclusion won't work
# ignore all . files and . folders .* # ignore all . folders but include .files .*/ # trailing / means directory # ignore all . files but include . folders .* !.*/
Single asterisk path applies rule only to current directory (where the .gitignore file is located)
.ext # excludes files named .ext in current dir *.ext # excludes files with .ext extension in current dir
Double asterisk path recursively applies rule to all subdirectories
# ignore files with .ext suffix in any directory depth **/.ext