1

If the .gitignore file looks like this:

*
!adir/

then the directory adir will not be included. However, if I change it to:

*/
!adir/

Now it works - all directories are ignored but adir. Why is that? What is the proper way of ignoring everything but some particular directories?

EDIT: Based on the answer, I changed it to:

*
!adir/
!adir/*

and it works. But is there any preferred way?

Xufeng
  • 6,452
  • 8
  • 24
  • 30
  • See http://stackoverflow.com/questions/5241644/using-gitignore-to-ignore-everything-but-specific-directories for some good ideas. – OnlineCop Mar 02 '14 at 03:15
  • Please don't add your tag (e.g. git) at the front of your question (and please use a more descriptive title next time). This time, I edited that in for you. Thanks ;-) – Uli Köhler Mar 02 '14 at 03:17

1 Answers1

1

This is because when you wrote *, git understood "ignore every files".

Git doesn't version folders, only files, so it saw adir/ as an empty directory.

Simon Boudrias
  • 42,953
  • 16
  • 99
  • 134