Unstage all deleted files in Git Unstage all deleted files in Git git git

Unstage all deleted files in Git


The output of git status --porcelain is a great way to build one-liners and scripts for tasks like this:

git status --porcelain | awk '$1 == "D" {print $2}' | xargs git reset HEAD


In case your path-/filenames returned from git status containspace characters, the call to awk can be modified to include theentire (quoted) path/filename including spaces:

git status --porcelain|awk '$1 == "D" {print substr($0, index($0,$2))}'|xargs git reset HEAD


Just in case anyone else uses git with PowerShell, here is a powershell version of @jefromi's excellent answer:

git status --porcelain | where { $_.StartsWith(" D") } | foreach-object { git reset HEAD $_.replace(" D ", "") }