git restore --source=HEAD --staged --worktree -- aDirectory
# or, shorter
git restore -s@ -SW -- aDirectory
With Git 2.23 (August 2019), you have the new command "git Restore"
This would replace the index and the work tree with the content HEAD
Note that:
git checkout -- <path>
does not perform a full reset: replaces the contents of the working tree with the prepared content.
git checkout HEAD -- <path>
makes a definitive reset to a path, replacing the index and the work tree with the commit version HEAD
.
If you have extra files in the work tree that do not exist in HEAD, a git checkout HEAD -- <path>
shall not remove them.
Note: With git checkout --overlay HEAD -- <path>
(Git 2.22, Q1 2019), the files that appear in the index and in the work tree, but not in <tree-ish>
are removed, to make them correspond exactly to <tree-ish>
.