Possible Duplicate:
Git – Whitelisting files in a complex directory structure
I’d like to have a git repository track only files named e.g. SOURCES while everything else shall be ignored (take e.g. a tree of pdf files where each SOURCES file lists their origins). The simplest shot would have been
*
!SOURCES
in .gitignore. However the exclusion of e.g. A/SOURCES is overridden by the *, requiring me to use git add -f. How can .gitignore be modified to ignore everything except files named SOURCES without requiring a forced add?
edit The solution posted here will not do since the directory structure is not fixed, i.e. new directories containing a SOURCES file should not have to be added to .gitignore by hand…
You can’t achieve this using just
.gitignoreGit doesn’t track paths. It tracks objects (~ files) only.
So, why don’t you reverse the tables:
or
Or get out the big guns:
or even
Untested idea Perhaps something like this could be in a pre-commit hook?
Update An idea for more automation:
Add this to .git/config
Now, you can just say
and it will automatically add the
*/*/SOURCES