34

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.

Community
  • 1
  • 1
Daniel DiPaolo
  • 55,313
  • 14
  • 116
  • 115
  • @miku +1, voted to close as well (and leaving it here because it's [best practice](http://meta.stackexchange.com/questions/230/duplicate-question-etiquette-to-delete-or-not-to-delete) apparently), surprised that didn't show up when posting – Daniel DiPaolo Mar 09 '11 at 18:54
  • Soon, you will be able to see both changes (staged and unstaged) with `git status -v -v`: see http://stackoverflow.com/a/29116346/6309. – VonC Mar 18 '15 at 07:37

1 Answers1

55

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

git diff --cached
Daniel DiPaolo
  • 55,313
  • 14
  • 116
  • 115