How do I show uncommitted changes in Git?
I STFW'ed, and these commands are not working:
teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice)
$ git status
On branch teyan/psservice
Your branch is up-to-date with 'origin/teyan/psservice'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: psservice.c
modified: psservice.vcxproj.filters
teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice)
$ git diff
teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice)
$ git diff master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
I had a situation of git status
showing changes, but git diff
printing nothing, although there were changes in several lines. However:
$ git diff data.txt > myfile
$ cat myfile
<prints diff>
Git 2.20.1 on raspbian. Other commands like git checkout
, git pull
are printing to stdout without problems.
For me, the only thing which worked is
git diff HEAD
including the staged files, git diff --cached
only shows staged files.
You have already staged the changes (presumably by running git add
), so in order to get their diff, you need to run:
git diff --cached
(A plain git diff
will only show unstaged changes.)
For example:
Source: Stackoverflow.com