Show git diff on file in staging area

arod picture arod · Aug 20, 2010 · Viewed 318.8k times · Source

Is there a way I can see the changes that were made to a file after I have done git add file?

That is, when I do:

git add file
git diff file

no diff is shown. I guess there's a way to see the differences since the last commit but I don't know what that is.

Answer

mipadi picture mipadi · Aug 20, 2010

You can show changes that have been staged with the --cached flag:

$ git diff --cached

In more recent versions of git, you can also use the --staged flag (--staged is a synonym for --cached):

$ git diff --staged