How to .gitignore all files/folder in a folder, but not the folder itself?

Aron Woost picture Aron Woost · Nov 22, 2010 · Viewed 360.2k times · Source

Possible Duplicate:
How do I add an empty directory to a git repository

I want to check in a blank folder. How can I do this?

Answer

Trianam picture Trianam · Apr 7, 2011

Put this .gitignore into the folder, then git add .gitignore.

*
*/
!.gitignore

The * line tells git to ignore all files in the folder, but !.gitignore tells git to still include the .gitignore file. This way, your local repository and any other clones of the repository all get both the empty folder and the .gitignore it needs.

Edit: May be obvious but also add */ to the .gitignore to also ignore subfolders.