简体   繁体   English

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

[英]GIT bash not recognizing changes to “.classpath” file via “git diff”

I was using command line GIT GNU bash as GIT client, to check in my Java project that I worked on in Eclipse. 我使用命令行GIT GNU bash作为GIT客户端,以检入在Eclipse中工作过的Java项目。

As part of the work, I changed some project build settings, which in Eclipse are recorded in a hidden (.dot) file called " .classpath " in the project's root directory. 作为工作的一部分,我更改了一些项目构建设置,这些设置在Eclipse中记录在项目根目录中一个名为“ .classpath ”的隐藏(.dot)文件中。

For some reason git diff refused to recognize the change: 由于某些原因, git diff拒绝识别更改:

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

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

However, I could see that the file changed, with a recent timestamp (and could prove that it changed by explicitly doing git commit and pushing the change): 但是,我可以看到文件已更改,带有最近的时间戳(并且可以通过显式执行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, version 4.3.46(2)-release (x86_64-pc-msys) GNU bash版本4.3.46(2)-发行版(x86_64-pc-msys)

git diff without any options or arguments shows the change between your working tree and the index. 没有任何选项或参数的git diff显示工作树和索引之间的变化。 Most probably your changes were staged for commit (via git add ). 您的更改很可能已经上演了提交(通过git add )。 You could run git status to verify that. 您可以运行git status进行验证。 To see such changes (ie the diff between the index and HEAD ) you should have run git diff --staged . 要查看此类更改(即索引和HEAD之间的差异),您应该运行git diff --staged

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM