git:为什么git diff不显示任何差异? [英] git: Why doesn't git diff show any differences?

查看:1185
本文介绍了git:为什么git diff不显示任何差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在回购上运行"git status",它将给出:

If I run 'git status' on my repo it gives:

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified: myfile

但是,如果我执行"git diff myfile",则没有任何区别.这是因为我进行了更改并删除了它,所以它又恢复了原始状态吗?

However, if I do a 'git diff myfile' it shows no differences. Is this because I have made a change and removed it so it is back to the original?

我应该运行'git checkout myfile'清除它吗?

Should I run 'git checkout myfile' to clear it?

推荐答案

您的文件已经登台提交.您可以使用git的--cached选项来显示差异.

Your file is already staged to be committed. You can show it's diff using the --cached option of git.

git diff --cached myfile

要取消登台,只需执行git status在其输出中建议的内容即可;)

To unstage it, just do what git status suggests in it's output ;)

您可以检查 Git索引有关更多信息.

You can check The Git Index For more info.

这篇关于git:为什么git diff不显示任何差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆