Nathan McDaniel Nathan McDaniel - 1 year ago 129
Git Question

Does git support wildcards in paths?

I have looked, searched, and read documentation and can't really find anything about this.

Basically, I want to be able to do this:

git reset -- *.exe


git reset -- */some_executable.exe

Instead of this:

git reset -- some/very/long/path/some_executable.exe

Also it'd be nice to be able to do this:

git reset -- topleveldirectory/another/subdirectory/*

Instead of this:

git reset -- topleveldirectory/another/subdirectory/SomeFile.cpp
git reset -- topleveldirectory/another/subdirectory/SomFile.h

I think I can use the wildcard
in git-add to add files, but haven't found anything that works in the case above.

Any suggestions or pointers to where I can look for more info?

Using: git version on 64-bit Windows 7

Answer Source

Git does support some pathspec globbing, but you need to be careful to shell-escape the characters so they aren't interpreted by in your case, msys bash, which doesn't support more sophisticated wildcard expansion.

EDIT: Also, for your reset example, you can just pass the directory as an argument to git reset and git will operate recursively.

git reset my/long/path

rather than

git reset my/long/path/*
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download