Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top