Reputation: 3
I'm working on a project on linux, with git version 1.8.x . I tried to set some rules with .gitignore and quickly realized that listing everything you don't want to track is not what I actually want. So I tried instead to precise which patterns git should track, ie:
*
#code files
!**/*.cpp
!**/*.h
But then, git doesn't track any new files anymore. So is it possible to find a way to make it works? Moreover using !**.cpp works only for the currents folders files.
Thanks o/
Upvotes: 0
Views: 218
Reputation: 3551
Don't forget to add !.gitignore
so it doesn't ignore itself!
#ignore everything
*
#Whitelist subdirectories - thanks to @Gabriele Petronella
!*/
#except these:
!*.cpp
!*.h
!.gitignore
Upvotes: 0
Reputation: 108169
#Ignore everything
*
#Whitelist subdirectories
!*/
#Whitelist the gitignore itself
!.gitignore
#Whitelist .cpp and .h files
!*.h
!*.cpp
*
ignores everything, directories included. Explicitly whitelisting subdirectories still ignores the files they contain, but it allows you to whitelist recursively!*.fileext
as a pattern to whilelist single extensionsUpvotes: 2