dan dan - 8 months ago 45
Git Question

Git - some files are marked as changed but 'git diff' doesn't show anything

I am quite new to Git, thus maybe I am missing something here.

dan@one:/var/www/$ git status -s
M GoogleChromeExtension.js
M ApiClient.js

So clearly 2 files have been changed.

But when I run:

git diff

no output is shown. I was expecting to get the changes between my working copy and the latest commit.

I am sure yesterday everything was working as expecting...

Is it maybe because I haven't been pushing the changes to the remote server?

P.S.: I am using GitHub




Do a git diff --cached - it compares the HEAD and index, ie stuff added for commit.

Just a git diff is between index and working directory, so if all the changes have been staged for commit, you won' see anything in git diff

The third form is git diff <commit> which compares working directory and commit. So doing git diff HEAD will also give you the diff that you want as well.