Undo “git add <dir>”?

To remove a directory and everything inside it from the index,

git rm --cached -r dir

The --cached switch makes git rm operate on the index only and not touch the working copy. The -r switch makes it recursive.


You will want to use git rm --cached -r <dir>. this command will remove the staged directory contents from the index.

if the directory was already tracked you have to find new and old files manually and unstage them …

Probably run git reset <dir> after that to reset existing (and already tracked) files inside the directory.


Update 2019:

Simply run git reset directory, it will unstage all newly added files.

Tags:

Git

Git Reset