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

编程入门 行业动态 更新时间:2024-10-20 20:51:19
git:为什么git diff不显示任何差异?(git: Why doesn't git diff show any differences?)

如果我在repo上运行'git status',它会提供:

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

但是,如果我执行'git diff myfile',则不会显示任何差异。 这是因为我做了一个改变,并将其删除,以便它回到原始状态?

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

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

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?

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

最满意答案

您的文件已经上演提交。 你可以使用git的--cached选项来显示它的差异。

git diff --cached myfile

要取消它,只要做它的输出git状态建议;)

你可以查看Git索引了解更多信息。

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

git diff --cached myfile

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

You can check The Git Index For more info.

更多推荐

本文发布于:2023-08-05 06:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1428834.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:差异   diff   git   show   differences

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!