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?
The git status command will show you the different states of files in your working directory and staging area.
The git diff command shows the differences between the files in two commits or between your current repository and a previous commit.
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.
See 365git.tumblr.com post:
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With