Neil
Neil

Reputation: 25815

With git, how do you search for a file pattern with `git log` instead of a file path?

You can limit your git log search to a file like so:

git log [branch] -- foo.c

But how would you limit the search to a file pattern instead of a full path?

Upvotes: 13

Views: 9265

Answers (3)

Cascabel
Cascabel

Reputation: 496902

I tend to do things like this:

git ls-files [--with-tree=<branch>] [path] | grep '<pattern>' | xargs git log [branch]

Upvotes: 13

Jason Lewis
Jason Lewis

Reputation: 1314

Or just drop the leading ., i.e.:git log -- *foo.c, or even git log -- ./*foo.c

Upvotes: 14

ryanprayogo
ryanprayogo

Reputation: 11817

Use the --glob option.

Ref: http://git-scm.com/docs/git-log

Upvotes: -4

Related Questions