why `git diff` reports no file change after `git add`

git diff diffs against the index, not against your HEAD revision. By running git add, you've put the changes in your index, so of course there are no differences! Use

  • git diff HEAD to see the differences between your tree state and the HEAD revision, or
  • git diff --cached to see the differences between your index and the HEAD revision.

Please try git diff --staged command.

Alternative options available are listed below.

git diff

shows changes between index/staging and working files. Since, in your case, git add moved your files-with-changes to staging area, there were no modifications shown/seen.

git diff --staged

shows changes between HEAD and index/staging. git diff --cached also does the same thing. staged and cached can be used interchangeably.

git diff HEAD

shows changes between HEAD and working files

git diff $commit $commit

shows changes between 2 commits

git diff origin

shows diff between HEAD & remote/origin