In case your path-/filenames returned from git status contain
space characters, the call to awk can be modified to include the
entire (quoted) path/filename including spaces:
git status --porcelain|awk '$1 == "D" {print substr($0, index($0,$2))}'|xargs git reset HEAD
The output of
git status --porcelain
is a great way to build one-liners and scripts for tasks like this:Just in case anyone else uses git with PowerShell, here is a powershell version of @jefromi's excellent answer:
See the section 'Unstaging a staged file' in this book.
In case your path-/filenames returned from
git status
containspace
characters, the call toawk
can be modified to include the entire (quoted) path/filename including spaces: