在暂存区域中显示文件中的git diff [复制]

本文翻译自:Show git diff on file in staging area [duplicate]

Possible Duplicate: 可能重复:
How do I show the changes which have been staged? 如何显示已上演的更改?

Is there a way I can see the changes that were made to a file after I have done git add file ? 有没有办法可以看到我完成git add file后对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. 我想有一种方法可以看到自上次提交以来的差异,但我不知道那是什么。


#1楼

参考:https://stackoom.com/question/Enku/在暂存区域中显示文件中的git-diff-复制


#2楼

In order to see the changes that have been staged already, you can pass the -–staged option to git diff (in pre-1.6 versions of Git, use –-cached ). 为了查看已经进行过的更改,可以将-–staged选项传递给git diff (在1.6之前的Git版本中,使用–-cached )。

git diff --staged
git diff --cached

#3楼

You can also use git diff HEAD file to show the diff for a specific file. 您还可以使用git diff HEAD file来显示特定文件的差异。

See the EXAMPLE section under git-diff(1) 参见git-diff(1)下的EXAMPLE部分git-diff(1)


#4楼

You can show changes that have been staged with the --cached flag: 您可以显示已使用--cached标志暂存的更改:

$ git diff --cached

In more recent versions of git, you can also use the --staged flag ( --staged is a synonym for --cached ): 在更新版本的git中,您还可以使用--staged标志( --staged--cached的同义词):

$ git diff --staged
发布了0 篇原创文章 · 获赞 3 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/p15097962069/article/details/105345558