20

Normally I use git diff to check the changes of uncommited files (not yet git added) with the last commited one.

But after doing git add somefile (but not yet git commited), how to check the diff of that file?

Kokizzu
  • 24,974
  • 37
  • 137
  • 233
  • 2
    Check out http://stackoverflow.com/questions/1587846/how-do-i-show-the-changes-which-have-been-staged/1587877#1587877 . Seems to be a duplicate – Max Komarychev Mar 20 '15 at 06:41
  • yes it's duplicate.. (I didn't know if the correct term is `staged`) I have vote to close the question.. – Kokizzu Mar 20 '15 at 06:52
  • 1
    I think this question is easier to find if someone doesn't know the concept of staging area in Git. – sidney Sep 17 '20 at 08:49

1 Answers1

32

You can check

git diff --cached -- yourFile

That will diff between HEAd and the index.

http://images.abizern.org.s3.amazonaws.com/365git/Feb11/Git%20Diff%202.png

(from 365git.tumblr.com)

The -- helps separating the command from the parameters

See more on the double hyphen syntax in "Deleting a badly named git branch".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250