Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cancel a gitignore from a parent level directory

Tags:

git

Having a git repository based on the following directory structure:

DIR_A 
      +------DIR_B
      +------DIR_C
      +------DIR_D
      +------DIR_E

Having DIR_A have a .gitignore file that ignores "*.bin"

I want that .gitignore to be applicable to all subdirectory structures except DIR_E. I don't want to set a gitignore that is hardcoding all paths, since more could be added and things would require maintenance and therefore potential mistakes.... So the preferrable way is to have a single .gitignore that excludes DIR_E...

This is what I tried, but it does not seem to work:

.gitignore (content under DIR_A) :

*.bin
!DIR_E

Any ideas why this does not work?

like image 276
gextra Avatar asked Jan 24 '26 07:01

gextra


1 Answers

Try ignoring files rather than folders:

*.bin
!DIR_E/*.bin
like image 95
VonC Avatar answered Jan 25 '26 23:01

VonC