Search for regular expression file names

Is there a way to do something like git log <path>, but instead of using a regular expression instead of a path? I want to search for commits containing files whose file names match a given pattern ...

... and while we are on it: is there a way to do git status/ git diffonly for file names that match a given pattern?

Thanks in advance!

EDIT : I would be awesome, if possible, would also work on Git v1.7.1.

+4
source share
4 answers

For a simple template, you can try, for example:

find . -name "*.c" | xargs git log

For a fullscreen regex, you can use:

find . | grep "REGEX" | xargs git log

If you need previously deleted files to be included in the output, you can use

git log --all --pretty=format: --name-only --diff-filter=A | sort -u | grep "REGEX" | xargs git log --

, , - git, answser .

+3

git, , glob.

git log -- '*.json'

, json. git status.


, diff commit. git log --grep -S .

.

+4

Thanks to your answers (especially to Greg and Michael) I myself developed my own path. (Hope this turns out to be viable):

git log --name-only --pretty="format:"|sort -u|egrep '<REGEX>'|xargs git log --
0
source

Can you do something like:

git log | grep [string_to_look_for]
-1
source

All Articles