Julian Yap

Running 'git diff' returns nothing

I was surprised when I ran a 'git diff' command and it returned nothing.

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#   new file:   404.html
#   modified:   _layouts/default.html
#   modified:   atom.xml
#   modified:   index.html
$ git diff

Coming from a background of using Mercurial, this kind of confused me.

The default output for git diff is the list of changes which have not been committed/added to the index. If there are no changes, then there is no output.

In my case I had already run a 'git add' so my changes were 'staged'.

In this case, just run either of these commands:

git diff HEAD
git diff --cached

Based off answers from "here.":http://stackoverflow.com/questions/3580608/git-diff-does-nothing

9 DECEMBER 2011 @ 12:00AM


Follow Me

Google+ RSS