Skip to content

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

Answered by KariCowan
KariCowan asked this question in General
Discussion options

You must be logged in to vote

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

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant