How to filter git diff based on file extensions?

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'

Leave a Comment