-1

Here is the folders:

--dir  
----subdir1  
------a.h  
------a.cpp  
----subdir2  
------b.h  
------b.cpp  
----.gitignore  

Please tell me how to track all but only .h, .cpp, .xmlfiles in dir and all its subdirectories. Here is my .gitignore file:

*
!.gitignore
!*.cpp
!*.xml
!*.h
!*.c
phd
  • 82,685
  • 13
  • 120
  • 165
fizzbuzz
  • 159
  • 1
  • 1
  • 8

1 Answers1

1

The .gitignore file you shared will not not ignore .cpp, .h, .c or .xml files in the project's root directory. From the problem statement, it seems like you want to track these files recursively in subdirectories, which you can do using the ** operator:

*
!.gitignore
!**/*.cpp
!**/*.xml
!**/*.h
!**/*.c
Mureinik
  • 297,002
  • 52
  • 306
  • 350