I created a new file file.txt
in my working tree. git status
shows this correctly:
$ git status
On branch mybranch
Untracked files:
(use "git add <file>..." to include in what will be committed)
file.txt
nothing added to commit but untracked files present (use "git add" to track)
However, git diff
shows nothing.
$ git diff
I found some related issues indicating the pager might be a problem, so I tried
git --no-pager diff file.txt
and
GITPAGER=cat git diff file.txt
with the same empty result.
If I add the file and then diff to HEAD, I get a correct diff.
$ git add file.txt
$ git diff --cached
diff --git a/file.txt b/file.txt
new file mode 100644
index 0000000..f2d7933
--- /dev/null
+++ b/file.txt
@@ -0,0 +1 @@
+asds
\ No newline at end of file
This is all on Windows 10 and the latest git version.
Why is the diff empty? Normally, I wouldn't care that much but another tool I'm using is relying on the diff output.