How do I remove a directory subtree from the staging area?

Acorn picture Acorn · Mar 19, 2011 · Viewed 44.8k times · Source

I made a new repository, and ran git add -A. I then noticed that there was a folder containing about 100 files that shouldn't have been included, so I added it to .gitignore.

How do I now clear the staging area so that I can add all my files again taking into account the updated .gitignore?

Answer

Greg Bacon picture Greg Bacon · Mar 19, 2011

In #git, you said you unintentionally added a directory that should have been ignored, so run

git rm --cached -r directory-name

to recursively remove the tree rooted at directory-name from the index.

Don't forget to update .gitignore!