how do i ignore file types in un-ignored folder
<p>I have a folder (<strong><em>mainRoot</em></strong>) that contains a complex structure. Except a folder (<strong><em>sources</em></strong>) and all it's children folders and files, everything is ignored. </p>

<p>On top of this, it'd like to ignore all files with a certain extension (<strong><em>.cache</em></strong>) in the un-ignored folder and all it's children folders and files(<strong>sources</strong>). How can I do so?</p>

<pre><code>!.gitignore
mainRoot/*
!mainRoot/sources/
!mainRoot/sources/*
!mainRoot/sources/**/*

#everything is fine till this point. 
#my intuition calls of an ignore like this
#but it doesn't seem to work

mainRoot/sources/*.cache
mainRoot/sources/**/*.cache
</code></pre>