title: Git: Exclude a file with git clean
body: <p>i'm working on a big python project, and i'm really sick if .pyc and *~ files. I'd like to remove them. I've seen that the <code>-X</code> flag of git clean would remove untracked files. As you can imagine, i'm not tracking <code>.pyc</code> nor <code>*~</code> files. And that would make the trick. The problem is that i've a <code>local_settings.py</code> file that I'd like to keep after the git clean.</p>
  
  <p>So, this is what I've got.</p>
  
  <p>.gitignore:</p>
  
  <pre><code>*.pyc
  *~
  local_settings.py
  </code></pre>
  
  <p>When I execute this command:</p>
  
  <pre><code>git clean -X -n -e local_settings.py
  </code></pre>
  
  <p>I get this list of results:</p>
  
  <blockquote>
    <p>Would remove local_settings.py<br>
    Would remove requirements.txt~<br>
    Would remove (other bunch of) ~ files<br>
    Would remove (other bunch of) pyc files  </p>
  </blockquote>
  
  <p>I don't want to remove the local_settings.py file. I've tryed lots of ways to do it, but i can't figure out how to acomplish it.</p>
  
  <pre><code>git clean -X -n -e local_settings.py
  git clean -X -n -e "local_settings.py"
  git clean -X -n --exclude=local_settings.py
  git clean -X -n --exclude="local_settings.py"
  </code></pre>
  
  <p>And nothing seems to work.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>For posterity, the right way to do it is (Thanks @Rifat):</p>
  
  <pre><code>git clean -x -n -e local_settings.py # Shows what would remove (-n flag)
  git clean -x -f -e local_settings.py # Removes it (note the -f flag)
  </code></pre>