Get a Git diff of the previous commit
Getting a diff (patch-file style display of changes) from a your most recent commit is useful when you commit and it lists three lines changing in a file instead of one. Of course, you should have run git diff --cached before git commit -m "I know what I'm doing.", but when you haven't, or have another reason to take one step back in the history of your work, here is the command that saves looking up the git commit hash.
git diff HEAD^ HEAD
(HEAD^ means the previous version of head; leaving off the second HEAD would show any uncommitted changes lying around as well.)
To limit to a particular file, in this case "midbucket.view.inc" in the directory from which we run the command:
git diff HEAD^ HEAD -- midbucket.view.inc
Reference
http://www.kernel.org/pub/software/scm/git/docs/git-diff.html


Comments
Post new comment