git diff
thinks there are no changes..even if git status
reports them as modified?
$ git status
On bra
Because git diff
by default checks differences between the staging area and your working copy. When you git add
, your staging area matches your working copy and therefore diff reports no changes.
Adding the --cached
flag tells diff to diff against HEAD
.
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
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, orgit diff --cached
to see the differences between your index and the HEAD
revision.Ran into the exact same problem.
You will see that filename1.c got committed.