1144

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.

Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
arod
  • 13,481
  • 6
  • 31
  • 39

3 Answers3

1824

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
mipadi
  • 398,885
  • 90
  • 523
  • 479
200

In order to see the changes that have been staged already, you can pass the -–staged option to git diff (in pre-1.6 versions of Git, use –-cached).

git diff --staged
git diff --cached
Arturo Herrero
  • 12,772
  • 11
  • 42
  • 73
75

You can also use git diff HEAD file to show the diff for a specific file.

See the EXAMPLE section under git-diff(1)

Empty2k12
  • 475
  • 12
  • 34
J-16 SDiZ
  • 26,473
  • 4
  • 65
  • 84
  • 22
    This shows both the diffs in the staged and non-staged files. This is what I was looking for. Thanks – NHDaly May 05 '16 at 19:53