find all git commits for a file type

4.3k Views Asked by At

its pretty simple to find all the commits containing a particular file.

git log -- .\Database\Tables\sometable.sql

but is there a simple way to find all the commits for a file type (recursively down child directories?) or will I need to write a script to do this?

(conceptually...)

git log -- .\Database\*.sql --recursive
2

There are 2 best solutions below

6
On BEST ANSWER

It appears that perhaps you just need to escape the * so that it doesn't get expanded by the command line. It would seem that you are on Windows so... but I am on Linux and tested like so:

git init
mkdir -p blue/red/green
touch blue/red/green/colors
git add blue/red/green/colors
git commit -m "colors and dirs"
touch blackAndWhite
git add blackAndWhite
git commit -m 'b&w'
git log -- \*ors

The result on the last git log is:

commit 8fdb718b5b616dd495c00eb7a6d123c33f7707e5
Author: <snipped>
Date:   Sun Oct 14 19:49:43 2012 -0400

    colors and dirs

On the Windows escaping of *... perhaps put it in either single or double quotes? I'll add if I figure something out.

0
On

I wanted to see all contributions by type for all users in my repository. I found a Ruby package that will do this, git fame (here). If you type git fame . --by-type it will output something like this:

enter image description here