title: Make git reset restage deleted files
body: <p>Let's say I deleted <code>fileA</code> in commit <code>abc123</code>. Then, when I <code>git reset</code>, the output of <code>git diff</code> shows that <code>fileA</code> was deleted. <code>fileA</code> is no longer in my working directory, so I can't re-add it.</p>
  
  <p>The default for <code>git reset</code> is <code>git reset --mixed</code>. This is described in <code>man git-reset</code> as:</p>
  
  <blockquote>
    <p>Resets the index but not the working tree (i.e., the changed files are
    preserved but not marked for commit) and reports what has not been
    updated.</p>
  </blockquote>
  
  <p>What's an elegant solution. One workaround is to checkout the later commit that contains the file, copy the file, and then checkout <code>abc123</code> and add it again.</p>
  
  <p><strong>SOLUTION</strong>:</p>
  
  <p>Two solutions below are correct. One shows how to recover the file if you checkout the commit at which it was deleted, and you simply run <code>git checkout fileA</code>. The other shows how to recover the file in the present commit that's later that the commit at which <code>fileA</code> was deleted. You run <code>git checkout abc123~ -- file A</code> (The <code>--</code> ensures that the checkout command know that we are trying to roll back a file and not change branches).</p>