View diff of staged changes in git

Daniel DiPaolo picture Daniel DiPaolo · Mar 9, 2011 · Viewed 26.2k times · Source

Possible Duplicate:
How do I show the changes which have been staged?

Is there a simple way to view the diff of only the staged changes I have pending in git? I've staged several files but want to take one last look at what I'm committing before I push the button. I have several other unstaged changes that I want to go in a separate commit, so unstaging, doing git diff, and then paging through to the file I want isn't all that desirable an option.

Example:

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   foo.java
#
# Changed but not updated:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   bar.java
#       modified:   baz.java
#       modified:   qux.java

I really just want to see what I changed in foo.java without having to unstage.

Answer

Daniel DiPaolo picture Daniel DiPaolo · Mar 9, 2011

One more minute of Googling found the answer of course, answering my own question:

git diff --cached