How do I use 'git ls-tree' to limit to certain filetypes?

git ls-tree -r --name-only HEAD | while read filename; do
  echo "$(git log -1 --format="%ai" -- $filename) $filename"
done

The above snippet will show me the last-modified dates of files in the current commit.

Is there a way to return only the jpg, gif, and css files?

Ideally, I’d love to know how I get a list of those and show only the ones that were modified since the last commit, but I’d settle for a list that limited to just those filetypes.


git ls-tree -r --name-only HEAD | grep ".\.css" | while read filename; do  
echo "$(git log -1 --format="%ai" -- $filename) $filename"  
done

I’ve realized I can add a grep to my request and limit to the filetype that way.  Now I want to know how can I limit my search to just specific folders in the file system?  It would speed it up a lot if I can limit where I search.

I kept digging… I worked out you can just add the path.  You know what they say, when all else fails, RTFM.

example:

git ls-tree -r --name-only HEAD src/main/webapp/assets/master-template/ | grep “…css” | while read filename; do
echo “$(git log -1 --format=”%ai" – $filename) $filename"
done