开发者

Git - some files are marked as changed but 'git diff' doesn't show anything

I am quite new to Git, thus maybe I am missing something here.

dan@one:/var/www/$ git status -s
M  GoogleChromeExtension.js
M  ApiClient.js

So clearly 2 files have been changed.

But when I run:

git diff

no output is shown. I was expecting to get the chan开发者_高级运维ges between my working copy and the latest commit.

I am sure yesterday everything was working as expecting...

Is it maybe because I haven't been pushing the changes to the remote server?

P.S.: I am using GitHub

Thanks,

Dan


Do a git diff --cached - it compares the HEAD and index, ie stuff added for commit.

Just a git diff is between index and working directory, so if all the changes have been staged for commit, you won' see anything in git diff

The third form is git diff <commit> which compares working directory and commit. So doing git diff HEAD will also give you the diff that you want as well.


Depending on exactly what is going on, there may be two solutions to this. It would be best if you didn't use short mode since it hides information important for debugging this.

If you expect changes, try running git diff HEAD to compare the working directory to the last commit. If you have already git added the changes, the default git diff action will be to not show those differences. See the http://git-scm.com/docs/git-diff man page DESCRIPTION which talks about this. The git status output (without -s) would help everyone see whether this was the case.

Alternately, if you didn't expect changes, this could be an OS/filesystem problem. Please report your OS and filesystem information.


use --no-pager flag with diff

git --no-pager diff filepath/filename.extn


Make sure that you're not actually within another git repository. And if for some reason above commands fails, try to run:

git show HEAD


I just recently had this problem, and found it happened because I changed my .gitattributes file for the repository. Have you changed any of your .gitattributes files recently? Are all the files that are changed of the same type? My recent issues affected *.sql files, for example. When I undid the change to .gitattributes, the source files became unchanged again.


git diff doesn't show the difference between last two commits. git diff shows difference between last commit and the changes you have done to your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜