I\'m using
git diff mycommit
for comparing my working tree with mycommit
, but it seems to ignore files not present in the current
A simple graphic might be of help:
So there are three types of diff you can ask for:
git diff --cached
This is the difference between what is in the index and the last commit. It shows you that changes that will be in the next commit.
git diff
This shows the difference in between the index and the working tree. These are the changes that you have made to files since you last added them to the index. This is why I wasn’t getting any results. I had no changes between the index and the working tree.
git diff HEAD
This shows the difference between the files in the working tree and the last commit. There is a gotcha here: if you've made changes, added them to the index, and then backed out these changes in the working tree, you’ll get no results for git diff HEAD
(because there is no difference) but you will get output for git diff --cached
because there are still changes in the index.
And if you want to compare it against previous commits:
This just compares against the previous commits, but you can replace HEAD~
with any other reference to a commit.