Search code examples
gitfilepattern

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


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!


Solution

  • for i in `git status --porcelain | grep '^D.*\.foo$' | sed 's/^D \+//'`; do
        git reset HEAD "$i"
        git checkout "$i"
    done