Let_Me_Be Let_Me_Be - 11 months ago 59
Git Question

Git diff ignore

Is it somehow possible to ignore certain files during git diff? I'm specifically interested in filtering out Makefile.in, Makefile, configure (and all that auto-generated crap).

Answer Source

You can try passing a list of files to git diff, and it will execute the diff only on those files.

Depending on how your code is setup, it can be as easy as:

git diff otherbranchname -- src/     # only give me diffs from src/

or as unsightly/complex as:

git diff otherbranchname -- $( git ls-files |
    perl -lne'next if /(?:[mM]akefile(?:\.in)?|configure|whateverelse)/;print' )
# diff all files which don't match the pattern

Depending on whether the files you want to ignore are managed by Git in the current branch or not, you'll need to replace the git ls-files with a find *; use instead a find . and add |.git to the Perl expression.

Tailor this as you see fit, possibly using the directories / file names you know you'd like to diff, rather than using the git ls-files or find.