Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View diff of staged changes in git [duplicate]

Tags:

git

git-diff

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.

like image 893
Daniel DiPaolo Avatar asked Mar 09 '11 18:03

Daniel DiPaolo


People also ask

How do you find the diff in your staging area?

If your changes are already staged, then there's no difference to show. But there's a command line option that will show you staged changes if you specify it: git diff --staged . With the --staged option, git diff will compare your staged changes against the previous commit.

Which command will show the differences between the staged and committed versions of the file?

The git diff command shows the differences between the files in two commits or between your current repository and a previous commit.


1 Answers

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

git diff --cached 
like image 153
Daniel DiPaolo Avatar answered Sep 30 '22 11:09

Daniel DiPaolo