How to remove a file from the staging area (= index = cache) in Git?

Question

EDIT This question can be understood in two ways, and the optimal answer is different in the two cases.

  • Question 1: I added a previously untracked file to the staging area. How can I remove this file from the staging area without removing it from the file system?

    Answer 1: Use the following command, as described in John Feminella's answer:

    git rm --cached <file>
    
  • Question 2: I modified a file already tracked, and added my modifications to the staging area. How can I remove my modifications from the staging area? I.e., how can I unstage my modifications in the file?

    Answer 2: Use the following command, as described in David Underhill's answer:

    git reset <file>
    

Answer

You want:

git rm --cached [file]

If you omit the --cached option, it will also delete it from the working tree. git rm is slightly safer than git reset, because you'll be warned if the staged content doesn't match either the tip of the branch or the file on disk. (If it doesn't, you have to add --force.)

How can I move a tag on a git branch to a different commit?

Git 'error: The branch 'x' is not fully merged'