When I used p4 (Perforce) I would often use the “…” pattern, which is sort of like “*” except it traverses levels of the file system hierarchy (ie: it also matches slashes). This was handy for dealing with source files that were several levels down the directory tree.
For example:
p4 diff foo/.../*.py
This would “p4 diff” all of the Python files under the subtree “foo”.
Is there an easy way to get the same result with git? Right now I have to do something like this:
git diff $(find foo -name '*.py')
which isn’t nearly as convenient.
git generally relies on the pathname expansion capabilities provided by the shell – and rightfully so, since pathname expansion is not exactly the job of a version control system. So you should be looking at your shell of choice to see if it supports something like the
...pathname expansion. If you’re using bash, you can set theglobstaroptionand then you can use a double asterisk to get the expansion you want:
Note that, based on my tests, the double asterisk doesn’t seem to match partial pathname components. In other words, it has to be followed by and preceded by a slash for that pattern to match something like
foo/bar/blah/baz.py. If you try writingfoo/ba**/*.pyit will match the same thing asfoo/ba*/*.py.