在暂存区域中的文件上显示 git diff
有没有办法可以在完成 git add file 后查看对文件所做的更改?
也就是说,当我这样做时:
git add file
git diff file
没有显示差异。我想有一种方法可以查看自上次提交以来的差异,但我不知道那是什么。
Is there a way I can see the changes that were made to a file
after I have done git add file
?
That is, when I do:
git add file
git diff file
no diff is shown. I guess there's a way to see the differences since the last commit but I don't know what that is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用
--cached
标志显示已暂存的更改:在较新版本的 git 中,您还可以使用
--staged
标志(- -staged
是--cached
的同义词):You can show changes that have been staged with the
--cached
flag:In more recent versions of git, you can also use the
--staged
flag (--staged
is a synonym for--cached
):为了查看已经暂存的更改,您可以将
--staged
选项传递给git diff
(在 1.6 之前的 Git 版本中,使用–-缓存
)。In order to see the changes that have been staged already, you can pass the
-–staged
option togit diff
(in pre-1.6 versions of Git, use–-cached
).您还可以使用 git diff HEAD file 来显示特定文件的差异。
请参阅
git-diff(1)EXAMPLE
部分代码>You can also use
git diff HEAD file
to show the diff for a specific file.See the
EXAMPLE
section undergit-diff(1)