How to filter git diff based on file extensions?

vfclists picture vfclists · Dec 18, 2011 · Viewed 47.8k times · Source

Is there an option to restrict git diff to a given set of file extensions?

Answer

CB Bailey picture CB Bailey · Dec 18, 2011

Yes, if you ensure that git expands a glob rather than your shell then it will match at any level so something like this (quotes are important) should work fine.

git diff -- '*.c' '*.h'