Git-一些文件被标记为已更改,但"git diff"不显示任何内容 [英] Git - some files are marked as changed but 'git diff' doesn't show anything
问题描述
我对Git相当陌生,因此也许我在这里错过了一些东西.
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
很明显,已经更改了2个文件.
但是当我跑步时:
So clearly 2 files have been changed.
But when I run:
git diff
未显示输出.我期望在我的工作副本和最新提交之间进行更改.
no output is shown. I was expecting to get the changes 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 .:我正在使用GitHub
P.S.: I am using GitHub
谢谢,
丹
推荐答案
执行git diff --cached
-它比较HEAD和索引,即为提交而添加的内容.
Do a git diff --cached
- it compares the HEAD and index, ie stuff added for commit.
在索引和工作目录之间只是一个git diff
,因此,如果所有更改都已进行提交,则您将不会在git diff
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
第三种形式是git diff <commit>
,它比较工作目录和提交.因此,执行git diff HEAD
也将为您提供所需的差异.
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.
这篇关于Git-一些文件被标记为已更改,但"git diff"不显示任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!