GIT bash 无法识别通过 "git diff" 对“.classpath”文件所做的更改

GIT bash not recognizing changes to ".classpath" file via "git diff"

我使用命令行 GIT GNU bash 作为 GIT 客户端,检查我在 Eclipse 中处理的 Java 项目。

作为工作的一部分,我更改了一些项目构建设置,这些设置在 Eclipse 中记录在项目根目录中名为“.classpath”的隐藏 (.dot) 文件中。

出于某种原因 git diff 拒绝承认更改:

user@HOST MINGW64 /c/_GIT/myserver (BRANCH1)
$ git diff .classpath

<==== crickets. Empty output!!!!

但是,我可以看到文件已更改,带有最近的时间戳(并且可以通过显式执行 git commit 并推送更改来证明文件已更改):

user@HOST MINGW64 /c/_GIT/myserver (BRANCH1)
$ git commit -m "remove test" .classpath

[BRANCH1 bd4c1c5] remove test
 1 file changed, 28 insertions(+)
 create mode 100644 .classpath

user@HOST MINGW64 /c/_GIT/myserver (BRANCH1)
$ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 610 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Simple Bitbucket Commit Checker
remote: Create pull request for BRANCH1:
remote:   http://GIT_URL....
remote:
To http://GIT_URL....
   77981fe..bd4c1c5  BRANCH1 -> BRANCH1

GNU bash,版本 4.3.46(2)-release (x86_64-pc-msys)

git diff 没有任何选项或参数显示工作树和索引之间的变化。您的更改很可能已准备提交(通过 git add)。您可以 运行 git status 来验证这一点。要查看此类更改(即索引和 HEAD 之间的差异),您应该 运行 git diff --staged.