9

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
Tim Jarvis
  • 18,465
  • 9
  • 55
  • 92

2 Answers2

9

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.

altendky
  • 4,176
  • 4
  • 29
  • 39
  • Just realized I do have my Windows laptop with Git here from work... in a Git bash window my 'script' above works fine. Perhaps your use of `\` as a path delimiter is just a slip-up? Or you have some other Windows Git client than I do? – altendky Oct 15 '12 at 00:25
  • Yeah, using posh-git (powershell) – Tim Jarvis Oct 15 '12 at 04:24
  • ok, so from the bash prompt it does work as I wanted. Must be a powershell thing like you suggest. – Tim Jarvis Oct 15 '12 at 04:50
  • If you can figure out how to escape the `*` in the powershell so it doesn't expand it, it should work there as well. I noticed that if the wildcards don't match anything in the current directory (Linux bash or Git bash) then they do get passed to `git log` and it does it's thing with them. The escape is only really necessary if the wildcard does match something. – altendky Oct 15 '12 at 11:18
  • annoying that I can't figure out how to escape the * in PS, but at least I can do what I need from bash, that'll have to do for now...unless someone knows how to escape the * – Tim Jarvis Oct 16 '12 at 02:51
  • Looking around it may be the accent grave/backtick `. Luck would have it that I'm not quite sure how to escape the backtick here on stackoverflow though. http://serverfault.com/questions/47811/what-is-the-literal-escape-character-in-powershell – altendky Oct 16 '12 at 11:10
0

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

inostia
  • 7,777
  • 3
  • 30
  • 33