Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why doesn't git track my directory?

Tags:

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/**'.

like image 572
Sunny An Avatar asked May 21 '26 02:05

Sunny An


1 Answers

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/
like image 153
Ry- Avatar answered May 22 '26 18:05

Ry-



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!