查看git中分阶段更改的差异

时间:2011-03-09 18:48:49

标签: git git-diff

  

可能重复:
  How do I show the changes which have been staged?

是否有一种简单的方法可以查看我在git中待定的暂存更改的差异?我已经上传了几个文件但是想在我按下按钮之前最后看一下我提交的内容。我还有其他几个未分阶段的更改,我想在单独的提交中进行,因此取消暂停,执行git diff,然后分页到我想要的文件并不是一个理想的选项。

示例:

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   foo.java
#
# Changed but not updated:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   bar.java
#       modified:   baz.java
#       modified:   qux.java

我真的只是想在foo.java看到我改变了什么,而不必取消演出。

1 个答案:

答案 0 :(得分:52)

Googling再多一分钟找到了答案,回答了我自己的问题:

git diff --cached
相关问题