title: Can't switch branches - "Error: Untracked working tree files..." should I do git add?
body: <p>I have this on my <strong>.gitignore</strong> file:</p>
  
  <pre><code>/nbproject/
  /app/runtime/
  /app/runtime/application.log*
  /app/runtime/error.log*
  /app/config/localdev.php*
  .DS_Store
  </code></pre>
  
  <p>1)
  I have checkout to <strong>master branch</strong> and then, checkout again, back to <strong>dev branch</strong>.</p>
  
  <p>2)
  Once I got back to <strong>dev branch</strong>, I lost all /nbproject/ files and all /app/config/localdev.php as well !!!
  And perhaps the others, but since they are autogenerated by php framework uppon runtime, I can't really tell!</p>
  
  <p>3)
  I then switch back to the <strong>master branch</strong> and I got those files there.</p>
  
  <p>4)
  I've copy those files somewhere else, and I've switched to <strong>dev branch</strong> again.</p>
  
  <p>5)
  I've place those missing files back inside /nbproject/ folder.</p>
  
  <p>Now, if I try to switch to the Master branch, I'm getting this:</p>
  
  <pre><code>Error: The following untracked working tree files would be overwritten by checkout:     
      nbproject/private/config.properties      
      nbproject/private/private.properties     
      nbproject/private/private.xml    
      nbproject/project.properties     
      nbproject/project.xml 
  
      Please move or remove them before you can switch branches.  
  
      Aborting
  </code></pre>
  
  <p>I'm aware that I should perhaps do a <code>git add .</code> to move those files on the repository, what I don't understand is:</p>
  
  <p>Why is git throwing this message IF I had nbproject/ ignored well before those git checkout commands being issued?</p>
  
  <p>Question:</p>
  
  <p>The point is to ignore those files. Both on master and dev. My question is: how can I fix this in order to: </p>
  
  <p>a) First:
  <strong>get those files (the ones on gitignore) back to dev ?</strong></p>
  
  <p>b) Second:
  <strong>make steps to avoid this conflict again.</strong></p>