How do I tell Git to ignore everything except a subdirectory?

Here how to ignore everything exept one directory "MY_SUPER_DUPER_TEMPLATE_directory" in some directory

Structure: /bitrix/templates/MY_SUPER_DUPER_TEMPLATE_directory

/*
!/bitrix
/bitrix/*
!/bitrix/templates
/bitrix/templates/*
!/bitrix/templates/MY_SUPER_DUPER_TEMPLATE_directory
*.DS_Store
*.gitignore

This ignores root files & root directories, then un-ignores the root bin directory:

/*
/*/
!/bin/

This way you get all of the bin directory, including subdirectories and their files.

Tags:

Git

Gitignore