Zantier Zantier - 14 days ago 6
Git Question

git diff filtered by file name

I would like the results of

git diff
to be filtered by the file name.

In particular, I want a diff for all of the files named "AssemblyInfo.cs", but located anywhere within the git repository.

I am using git on Cygwin, if that makes a difference.

Answer

File arguments to git diff need to be delimited by -- - try this:

find . -name <pattern> | xargs git diff --

xargs makes sure spaces, tabs, newlines, etc are handled correctly.

You could debug it with the --name-status argument to git diff. You could also try:

git diff --name-only | grep <pattern>

[edit] Try:

git diff --name-status -- `find . -name '<pattern>'`
ebg@taiyo(98)$ git diff --name-status -- `find . -name '*.scm'`
M       scheme/base/boolean.scm
M       surf/compiler/common.scm
M       surf/compiler/compile.scm
M       surf/compiler/expand.scm