We can see difference between repository and working directory with:
git diff We can see difference between repository and staging index with:
git diff --staged But how do we see difference between working directory and staging index?
Actually, git diff is between index and working tree. It just so happens that until you have staged changes to the index (with git add) that its contents will be identical to the HEAD commit.
git diff HEAD is between repo and working tree.
git diff is, by default,to show what has not yet been tracked (added to the index or committed). What you had to the index is no longer shown by default, because you already reviewed it and decided to make it part of the next commit.To illustrate that, I changed a file with “Name Staged” text and than I added it (git add .). After that, I changed the file again, now I replaced the text to “Name Working Area” and than I run the follow commands:
Now you can see clearly how it works. Pretty cool, right?
Inspired by @VonC's accepted answer, instead of git diff HEAD you can also write:
git difftool --dir-diff --no-prompt HEAD This will open a directory diff showing the differences between your working tree and the repo. From there it's pretty easy to view changes to individual files (e.g. when using a tool like Beyond Compare with its tabbed UI).