Read this question.
You want:
# Blacklist everything
*
# Whitelist all directories
!*/
# Whitelist the file you're interested in.
!*.cocci
Note, this’ll track only *.cocci files. Yours doesn’t work because you ignore everything (that’s the first line), which ignores all subdirectories.