'git status' shows changed files, but 'git diff' doesn't

Oliver P picture Oliver P · Jan 28, 2013 · Viewed 95.9k times · Source

I've had a look at all similar questions. However, I've double checked and something strange is definitely happening.

On one server (Solaris with Git 1.8.1) I cloned the Git repository then copied the .git folder into my existing live files. This worked perfectly, I could run

git status

then

git diff [filename]

to check any files that were different.

On another server (Solaris with Git 1.7.6) I'm doing exactly the same however

git diff [filename]

shows nothing, even if the contents of the file is definitely different. I have also tested adding a new file, committing it, and then editing. The same issue, git status shows the file as changed, but git diff shows nothing. If I download the changed file and run a diff locally then I get diff output.

Answer

atw picture atw · Feb 10, 2015

I added the file to the index:

git add file_name

and then ran:

git diff --cached file_name

You can see the description of git diff here.

If you need to undo your git add, then please see here: How to undo 'git add' before commit?