Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unstage all deleted files in Git

I want to unstage all file deletes. Is there an easy way?

I want to apply this to the file pattern of all deletes.

like image 308
Jacko Avatar asked Nov 22 '10 20:11

Jacko


2 Answers

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
like image 184
Cascabel Avatar answered Sep 22 '22 04:09

Cascabel


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
like image 44
rc0r Avatar answered Sep 20 '22 04:09

rc0r