From "Specifying revisions"
HEAD
names the commit on which you based the changes in the working tree.
There are other heads (FETCH_HEAD
, ORIG_HEAD
and MERGE_HEAD
). See Jefromi's answer for more.
The thing is, by default git diff
actually shows the differences between "the current state of your project" (i.e. your files on your working tree) and the index (not HEAD).
In other words, the differences are what you could tell git to further add to the index but you still haven't.
if you do git diff --cached
, then it will compare the index with HEAD.
See git book for more (archive link):
A common use is to simply run
$ git diff
which will show you changes in the working directory that are not yet staged for the next commit. If you want to see what is staged for the next commit, you can run
$ git diff --cached
which will show you the difference between the index and your last commit; what you would be committing if you run "git commit" without the "-a" option. (In Git versions 1.6.1 and later, you can also use
git diff --staged
which may be easier to remember.) Lastly, you can run$ git diff HEAD
which shows changes in the working directory since your last commit; what you would be committing if you run "git commit -a".
See also 365git: Getting a diff between the working tree and other commits:
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