0

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)

рüффп
  • 5,172
  • 34
  • 67
  • 113

1 Answers1

1

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

grimsock
  • 774
  • 5
  • 18
  • Your solution does not work on my machine (Centos 6.5) but if I use now: `git show 12f00d -- '*.xml'` it works as expected. – рüффп Oct 07 '15 at 12:51
  • It would be better to explain why we have to put single quotes as I did not find anything related to this in the documentation. – рüффп Oct 07 '15 at 12:55
  • Here's explanation: http://stackoverflow.com/questions/13321458/meaning-of-git-checkout-double-dashes?answertab=votes#tab-top – grimsock Oct 07 '15 at 13:52
  • This just explain the usage of `--` but not why to wrap the last parameter with single quote. – рüффп Oct 07 '15 at 15:58
  • It means that globbing will be done by git, not by your shell. – grimsock Oct 07 '15 at 23:04