title: git checkout branch without deleting the files deleted in it
body: <p>Here is the situation I'm facing:</p>
  
  <p>A directory full of generated files where commited to the repo by mistake. They obviously shouldn't have been, so I want to remove them:</p>
  
  <pre><code>$ git rm --cached foo/*
  $ cat &gt; foo/.gitignore
  *
  !.gitignore
  $ git add foo/
  $ git commit -m "Ignored stuff in foo"
  </code></pre>
  
  <p>This almost solves it, but leaves a different problem. When I want to <code>git fetch &amp;&amp; git checkout</code> on the production server, all the generated files in the foo/ directory will be removed. Is there some magic I could do about it on either side? Please not that simply ignoring them is not an option as they can be changed.</p>