git:为什么 git diff 没有显示任何差异?

标签 git git-diff git-status

如果我在我的仓库上运行“git status”,它会给出:

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

但是,如果我执行“git diff myfile”,它不会显示任何差异。这是因为我做了更改并删除了它,所以它又回到了原来的状态吗?

我应该运行“git checkout myfile”来清除它吗?

最佳答案

您的文件已暂存待提交。您可以使用 git 的 --cached 选项显示它的差异。

git diff --cached myfile

要取消暂存,只需执行 git status 在其输出中建议的操作即可;)

可以查看The Git Index了解更多信息。

关于git:为什么 git diff 没有显示任何差异?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4734844/

相关文章:

git - 显示提交之间的差异

过去提交的 git 状态?

git - 如何检查当前分支中是否没有要提交的内容?

git - 如何让 git-status 检查两个不同的 Remote ?

git - 将 Nitrous.io 连接到 Bitbucket Git SSH 公钥

git - 如何在 TeamCity 中构建 git 标签?

Python 脚本不删除 Windows 中的 Git 文件

Windows 上的 Git Diff 和 Meld

php - Git POST webhook shell_exec

git - 在单个压缩窗口中比较多个文件的差异