How to ignore all hidden directories/files recursively in a git repository?

Poe picture Poe · Nov 5, 2011 · Viewed 93.2k times · Source

I'd like to have Git ignore all hidden files and directories. i.e.

  • .aptitude
  • .ssh/
  • .bash_rc
  • config/.hidden

Is there a simple rule to cover this without specifically adding each entry?

Answer

Daniel Böhmer picture Daniel Böhmer · Nov 5, 2011

Just add a pattern to .gitignore

.*
!/.gitignore

Edit: Added the .gitignore file itself (matters if it is not yet commited).