git status shows changed files but git diff doesn't
I've had a look at all similar questions however I've double checked and something strange is definitely happening.
On one server (Solaris with git 1.8.1) I cloned the git repository then copied the .git folder into my existing live files. This worked perfectly, I could run
git status
then
git diff [filename]
to check any files that were different.
On another server (Solaris with git 1.7.6) I'm doing exactly the same however
git diff [filename]
shows nothing, even if the contents of the file is definitely different. I have also tested adding a new file, committing it then editing. Same issue, git status
shows the file as changed but git diff
shows nothing. If I download the changed file and run a diff locally then I get diff output.
There are a few reasons why git status
might show a difference but git diff
might not.
The mode (permission bits) of the file changed-- for example, from 777 to 700.
The line feed style changed from CRLF (DOS) to LF (UNIX)
The easiest way to find out what happened is to run git format-patch HEAD^
and see what the generated patch says.
I added the file to the index:
git add file_name
and then ran:
git diff --cached file_name
You can see the description of git diff here.
If you need to undo your git add, then please see here: How to undo 'git add' before commit?
For me, it had something to do with file permissions. Someone with Mac/Linux on my project seems to commit some files with non-default permissions which my Windows git client failed to reproduce. Solution for me was to tell git to ignore file permissions:
git config core.fileMode false
Other insight: How do I make Git ignore file mode (chmod) changes?
链接地址: http://www.djcxy.com/p/6168.html上一篇: 仅在Git中的一个目录中提交更改