One of the things I like about git, is the concept of working directory, index and repository. The index, or staging area, is really useful for gathering related changes before committing to the repostitory.
The GitGuys have a good description of the difference between these three.
Sometimes we will have changes in the working directory and/or the index. To compare differences between these different states:
|git diff –cached
|git diff HEAD
If you want to diff a particular file, add
-- filename to end of command e.g.
git diff -- src/sql/update_20140125a.sql
git diff --cached -- src/sql/update_20140125a.sql
To see contents of a file in a particular state
|git show :filename
|git show HEAD:filename
And to get a good understanding of how git works, take a look at Git from the inside out