I think you probably got confused with the concept of index, as @CB Bailey commented:
The staging area is the index.
You can simply consider staging directory and index as the same thing.
So, just like @Tim Henigan's answer, I guess:
you simply want to "undo" the git add
that was done for that file.
Here is my answer:
Commonly, there are two ways to undo a stage operation, as other answers already mentioned:
git reset HEAD <file>
and
git rm --cached <file>
But what is the difference?
Assume the file has been staged and exists in working directory too, use git rm --cached <file>
if you want to remove it from staging directory, and keep the file in working directory. But notice that this operation will not only remove the file from staging directory but also mark the file as deleted
in staging directory, if you use
git status
after this operation, you will see this :
deleted: <file>
It's a record of removing the file from staging directory. If you don't want to keep that record and just simply want to undo a previous stage operation of a file, use git reset HEAD <file>
instead.
-------- END OF ANSWER --------
PS: I have noticed some answers mentioned:
git checkout -- <file>
This command is for the situation when the file has been staged, but the file has been modified in working directory after it was staged, use this operation to restore the file in working directory from staging directory. In other words, after this operation, changes happen in your working directory, NOT your staging directory.