Search code examples
windowsgitgit-bashgit-diff

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.

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.

For some reason git diff refused to recognize the change:

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):

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)


Solution

  • git diff without any options or arguments shows the change between your working tree and the index. Most probably your changes were staged for commit (via git add). You could run git status to verify that. To see such changes (i.e. the diff between the index and HEAD) you should have run git diff --staged.