If I run git diff
I would expect to see a list of changes of my working directory relative to whatever had been committed before (or a list of the working direc
I had a LESS=-R
environment variable set. It made git diff
show a blank screen.
The solution for me:
unset LESS
I have seen situations where there really should be output from git diff
, but there isn't; adding
--no-pager
in between git
and diff
does work:
git --no-pager diff
...so does explicitly setting the pager to be less
with
git config --global core.pager 'less'
Even though less
is supposed to be the default pager.
This was in Ubuntu 12.04 LTS (Precise Pangolin).
I found the information about pager settings in the Git documentation.
GIT DIFF DOESN'T WORK AFTER STASH
Someone may run into this after attempting to apply stashed changes like I did.
git pull
) then git stash apply
(possibly with merge conflict)At this point simply stash your changes again (git stash
), do git pull
to ensure everything is up to date (because I'm paranoid about it), double check that all files are up to date in working directory (possibly run rsync if dealing with remote/local), then attempt to git stash apply
again and it should work!
In answer to the original question, git diff
isn't showing anything because you have a brand new directory, with a newly added file, but there are zero changes in the file for git diff to show. git status
is showing that you added a new file, but git diff
is for showing changes within files. If you made changes to the file, committed it, then made additional changes to it and ran git diff
it would then show you the changes to the file.