git diff thinks there are no changes..even if git status reports them as modified?
$ git status On branch master Your branch is ahead of 'origin/master' by 2 commits.   (use "git push" to publish your local commits)  Changes to be committed:   (use "git reset HEAD <file>..." to unstage)      new file:   file-added     modified:   file-with-changes   << it knows there are changes   but in order to see the difference, I need to explicitly add the last reversion hash..
$ git diff   (nothing)  $ git diff rev-hash diff --git a/file-with-changes b/file-with-changes index d251979..a5fff1c 100644 --- a/file-with-changes +++ b/file-with-changes . .. 
                Your file is already staged to be committed. You can show it's diff using the --cached option of git. To unstage it, just do what git status suggests in it's output ;) You can check The Git Index For more info.
The git diff command displays the differences between files in two commits or between a commit and your current repository. You can see what text has been added to, removed from, and changed in a file.
In git, files (per se) aren't staged, changes are. So when you do git add <filename> , it is the current state of that file that is staged. If you change the file and want to add those changes as well, you just do another git add .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With