'git status'显示更改的文件,但'git diff'不显示 [英] '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.
在一台服务器上(带有Git 1.8.1的Solaris),我克隆了Git存储库,然后复制了.git。文件夹放入我现有的实时文件。这很完美,我可以运行
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
然后
git diff [filename]
检查任何不同的文件。
在另一台服务器上(Solaris Git 1.7.6)但是我做的完全一样
On another server (Solaris with Git 1.7.6) I'm doing exactly the same however
git diff [filename]
不显示任何内容,即使文件的内容肯定不同。我还测试了添加新文件,提交并进行编辑。相同的问题 git status
显示文件已更改,但 git diff
没有显示。如果我下载更改后的文件并在本地运行diff,那么我会得到diff输出。
shows nothing, even if the contents of the file is definitely different. I have also tested adding a new file, committing it, and then editing. The 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.
推荐答案
我已将文件添加到索引:
git add file_name
然后运行:
git diff --cached file_name
您可以在此处看到说明。
如果您需要撤消git add,请在此处查看:如何在提交前撤消'git add'?
If you need to undo your git add, then please see here: How to undo 'git add' before commit?
这篇关于'git status'显示更改的文件,但'git diff'不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!