title: How can I ignore all files except those with a certain extension in git?
body: <p>I need to ignore all files except those ending in <code>.php</code>, <code>.css</code>, <code>.html</code> or <code>.js</code>.</p>
  
  <p>This is what I have in my .gitignore file for now:</p>
  
  <pre><code>*
  !.php
  !/*.php
  !*.php
  </code></pre>
  
  <p>It does ignore everything, but only permits <code>.php</code> files in root directory, while hiding all the rest.</p>