Alex Rivera | Logout

GIT: I want to unstage all files matching a certain pattern

Asked 2010-11-19T18:15:53.677
14

I would like to run

git reset *.foo

but this errors out.

I think I need to use a pipe, but I'm not sure how to do this.

Thanks!

Edit
Report

3 Answers

9
for i in `git status --porcelain | grep '^D.*\.foo$' | sed 's/^D \+//'`; do
    git reset HEAD "$i"
    git checkout "$i"
done
answered 2010-11-19T18:18:49.343
7

If you are using Powershell the following will work.

gci -re -in *foo | %{ git reset $_ } 
answered 2010-11-19T18:19:39.760
6

This should work in cygwin and unix env

git reset $(git diff --name-only --cached | grep *.foo)
answered 2013-04-29T09:37:36.833

Your Answer