gitposh-git

find all git commits for a file type


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

Solution

  • 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.