title: git add adding ignored files
body: <p>I'm trying to remove a previously tracked directory from git, which works, but it's being added back with each subsequent <code>git add .</code>, <code>git add -A</code>, etc. Here's what I've done:</p>
  
  <p>Add to .gitignore in root of project:</p>
  
  <pre><code>node_modules
  </code></pre>
  
  <p>Run the following:</p>
  
  <pre><code>git rm -r --cached node_modules
  git commit -a -m "removed node_modules"
  git push origin master
  </code></pre>
  
  <p>So far so good, this removes the directory from the remote repository. The problem is when I later run <code>git status</code> it tells me the node_modules directory is untracked and keeps adding it back on future commits.</p>
  
  <p>What am I missing and/or how do I find the root of my problem?</p>
  
  <p><strong>From <a href="http://git-scm.com/docs/git-add" rel="noreferrer">here</a>:</strong></p>
  
  <blockquote>
    <p>The git add command will not add ignored files by default.
    ...
    The git add command can be used to add ignored files with the -f (force) option.</p>
  </blockquote>
  
  <p><strong>Additional information from comments:</strong></p>
  
  <p>I am tracking .gitignore file.</p>
  
  <p><code>git check-ignore node_modules/</code> returns node_modules/ as expected.</p>
  
  <p>No use of submodules.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I've created a sample that appears to replicate the issue following the steps above:</p>
  
  <p><a href="https://github.com/awhitehouse104/SampleRepo" rel="noreferrer">https://github.com/awhitehouse104/SampleRepo</a></p>
  
  <p><strong>Resolution:</strong></p>
  
  <p>To summarize the answer and comments from below, the issue was in the encoding of my .gitignore file. I had used <code>echo 'node_modules' > .gitignore</code> to create the file on windows 8 and it came out as UTF-16 with BOM (according to answer below). After a few google searches, it seems this is the default encoding with powershell and I can confirm that saving as UTF-8 seems to have resolved the issue.</p>
  
  <p><strong>tldr;</strong> Probably don't use this method of creating .gitignore files or be prepared to change the encoding</p>
  
  <p><code>echo 'node_modules' > .gitignore</code></p>