I\'m using
git diff mycommit
for comparing my working tree with mycommit
, but it seems to ignore files not present in the current
The question is: I have added some file in my working tree, that exists in the other commit. Why is git diff
not showing me the difference between the file content that exists in my working tree and the content of the file that is in the other commit.
This is because the new file that you added is untracked and hence, well, git doesn't track it.
Try git diff HEAD
you won't see that you have added B.txt in your working tree.
Basically, diff does not take into account untracked files. That is why you see that the file is deleted, because the diff is same as git diff B A
Now, if you were to add the file, you will see the expected result, because git is tracking it now.
Say, you committed the file and then modify the content in the working tree:
Now, git diff HEAD
will show the difference between working tree and HEAD, showing the change you have done in your working tree on tracked files. Same with git diff B