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>
You want:
If you omit the
--cachedoption, it will also delete it from the working tree.git rmis slightly safer thangit 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.)