In a git pathspec, the pattern **/name.ext
will match name.ext
in any subdirectory, but not the current working directory. For example:
> git ls-files "**/CMakeLists.txt"
src/CMakeLists.txt
test/CMakeLists.txt
There seems to be no single pathspec to match all the CMakeLists.txt
within the current working directory tree. It would be convenient to have the behavior of find
:
> find . -name "CMakeLists.txt"
CMakeLists.txt
src/CMakeLists.txt
test/CMakeLists.txt
Since the usual idea of *
in expressions is to match “zero or more”, I would expect the normal behavior of git for pathspec **/name.ext
to match the current working directory as the “zero” part of **
, but it doesn’t work like that. While it’s possible to repeat the filename without glob (i.e., name.ext **/name.ext
), this is cumbersome and error-prone. Is there a more convenient alternative?