git: Why doesn't git diff show any differences?

Noam picture Noam · Jan 19, 2011 · Viewed 33.1k times · Source

If I run 'git status' on my repo it gives:

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified: myfile

However, if I do a 'git diff myfile' it shows no differences. Is this because I have made a change and removed it so it is back to the original?

Should I run 'git checkout myfile' to clear it?

Answer

Marcus Borkenhagen picture Marcus Borkenhagen · Jan 19, 2011

Your file is already staged to be committed. You can show it's diff using the --cached option of git.

git diff --cached myfile

To unstage it, just do what git status suggests in it's output ;)

You can check The Git Index For more info.