why doesn't git track my directory?

时间:2018-07-25 04:33:12

标签: git gitignore

I made a .gitignore file as belows:

## all files
*
## keep track
!bin

bin is a directory. However, if I make or change a file in the bin directory, it is not tracked at all. How can I fix it? I have also tried '!bin/*' and '!bin/**'.

1 个答案:

答案 0 :(得分:3)

Since * matches both bin itself and everything inside it, and Git doesn’t track empty directories, you need to exclude both of those:

*
!bin/
!bin/**

If you only meant to apply this sort of stuff to the same level as the .gitignore, a leading slash is needed to indicate that:

/*
!/bin/