Search code examples
gitfiltergit-diffgit-show

Git show <commit> and get diff for a file subset


I am looking for a solution to get the difference of a commit using git show <commit> command.

Usually I make:

$> git show 12f00d

And as expected, I get all diff for all files modified in the given commit.

Now I have a big commit (many files changed/moved) after a refactoring and I just need to know what changed in all the xml files recursively in this commit. I have plenty of .java, .xsl, .properties files and only few .xml files.

I tried the following commands without success:

$> git show 12f00d -L 0,0:*.xml 
    > incorrect syntax

$> git show 12f00d *.xml 
    > no result

$> git show 12f00d **/*.xml 
    > Return the root pom.xml but not recursively

$> git show 12f00d **/**.xml 
    > Return the root pom.xml but not recursively

$> git show 12f00d -- *.xml 
    > no result

$> git show 12f00d -- **/*.xml 
    > Return the root pom.xml but not recursively

$> git show 12f00d -- **/**.xml 
    > Return the root pom.xml but not recursively

I tried the same options with the command git diff <commit>.

I use the Git version 1.8.4 under Linux CentOS (bash terminal).

Do you know if such filter is possible with git (perhaps another command)


Solution

  • Try this: git show 12f00d '*.xml'