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

发布于 2024-10-21 12:55:57 字数 965 浏览 1 评论 0原文

可能的重复:
如何显示已上演的更改?< /a>

有没有一种简单的方法来查看我在 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 中更改了什么,而无需取消暂存。

Possible Duplicate:
How do I show the changes which have been staged?

Is there a simple way to view the diff of only the staged changes I have pending in git? I've staged several files but want to take one last look at what I'm committing before I push the button. I have several other unstaged changes that I want to go in a separate commit, so unstaging, doing git diff, and then paging through to the file I want isn't all that desirable an option.

Example:

$ 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

I really just want to see what I changed in foo.java without having to unstage.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏九 2024-10-28 12:55:57

谷歌搜索一分钟当然找到了答案,回答了我自己的问题:

git diff --cached

One more minute of Googling found the answer of course, answering my own question:

git diff --cached
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文