tags:

views:

88

answers:

3

Is there a git find analogue of git grep, i.e., something that will find a filename by pattern in the tree? I've gone through a lot of git documentation and not found this, but I'm having a hard time believing it doesn't exist somewhere.

A: 

Try git-ls-tree and run the output through grep(1)

Aaron Digulla
+1  A: 

It's simply:

git ls-files 'yourpattern'
Randal Schwartz
that almost works; it uses globs rather than regexps, and requires me to say `ls-files **/filename` rather than `ls-files filename`. seems weird that git can do regexp searches through the contents of files but not through their filenames.
Martin DeMello
+1  A: 

You can list all files in a tree object using git ls-tree -r --name-only --full-tree <treeish>. Pipe this through a regular grep to find what you're looking for.

Geoff Reedy
how about just `git ls-files` and pipe that through grep?
hasen j