Reputation: 31328
I am trying to show the diff between the last commit and the one before:
git diff HEAD^ HEAD <filename>
but that displays nothing. I know in fact that there is difference between the two commits.
What am I doing wrong and how should I correct it?
P.S.: I feel that this has been discussed many times before but somehow can't find any useful reference.
Upvotes: 2
Views: 695
Reputation: 5187
The changes you made in HEAD in a particular file are obviously not there in HEAD^ otherwise it wouldn't be part of the commit at all.
The command to see those changes is: git show HEAD -- <filename>
Upvotes: 0
Reputation: 1328342
It would display nothing if that particular file had no changes between HEAD^
and HEAD
.
Note that with git1.8.5+, you can do a:
git diff @^ -- afile
(@
means HEAD
)
git log -p -- aFile
would give all the SHA1 were a change for that file occurred.
(-p
for displaying the diff)
To see the last modification on a file (without having to deal with HEAD or other SHA1):
git log -1 -p -- aFile
Upvotes: 5