Ignore Files In Git .gitignore But Keep Directory

Updated about 1 yr, 5 mths ago (April 18, 2016). Know a better answer? Let me know!

Ignore files in Git .gitignore but keep directory

How to .gitignore all files in a directory, but keep the directory

Add this to a .gitignore file in the directory where you want to ignore all the files (and sub-directories etc.) but not ignore the actual directory itself.

*
!.gitignore

To do this from Windows command prompt:

(echo * & echo !.gitignore) >> ./.gitignore

More Information

 

Updated about 1 yr, 5 mths ago (April 18, 2016). Know a better answer? Let me know!

Related categories [coloured].

Comment on this article (no HTML, max 1200 characters):