https://stackoverflow.com/a/3338145/391104
I have tried all the following methods to query the difference between the last two commits that changed a given file (not just the most recent two commits, but two specific commits that had a specific effect). Unfortunately, none works for me.
git version 1.8.3.1
$ git diff HEAD^^ HEAD main.c
$ git diff HEAD^^..HEAD -- main.c
$ git diff HEAD~2 HEAD -- main.c
The only method that worked is to provide two commit hash versions.
Question> Do you know why I cannot use HEAD above to compare?
Here is what I have tried:
$ git lg1 abc.xml |head -n 3
* 3f13aa1 - (3 hours ago) test 2 - guest
* d59d3bc - (8 months ago) test 1 - guest
* 3a19f36 - (1 year, 2 months ago) test 0 - guest
$ git diff d59d3bc..3f13aa1 abc.xml
diff --git a/abc.xml b/abc.xml
index 5db0595..2790562 100644
--- a/abc.xml
+++ b/abc.xml
@@ -40,6 +40,12 @@
Hello
+ World
$ git diff HEAD~2 HEAD~1 abc.xml
$ git diff HEAD^^ HEAD abc.xml
$ git diff HEAD^^..HEAD abc.xml
$ git diff HEAD~..HEAD abc.xml