查看本地提交的git更改/差异,而不是推送到远程的提交

14

我有三个本地提交的 Git 提交记录,但还没有推送到 GitHub。我想查看这三个提交的所有更改/差异,该如何查看所有差异?

我尝试了:git log --branches --not --remotes

它显示了这三个提交记录,但没有显示每个提交的所有差异/更改。

commit c08fbb72ae6a06e8b2ff3dbbb96fb555a43f4136
Author: Justin <justin@mydomain.com>
Date:   Mon Sep 10 18:17:02 2012 -0700

    Updated order of requires in Requires.php

commit 041fe19a48269a8aea2ccf90f53568893d4e0158
Author: Justin <justin@mydomain.com>
Date:   Mon Sep 10 17:56:42 2012 -0700

    Checking for app.config.php in Requires.php

commit 61c103a8a122bcde2311d081a8340ee1dd71997c
Author: Justin <justin@mydomain.com>
Date:   Mon Sep 10 17:42:20 2012 -0700

    Version bump 0.4.0. See CHANGELOG.md
感谢您的帮助。

4
如果您想查看每个提交的差异,请使用git log -p --branches --not --remotes命令。 -p代表补丁(patch),它将显示每个提交的统一差异(unified diff)。 - John Szakmeister
2个回答

17

您可以使用git diff来实现:

git diff origin/master..HEAD

假设您的HEAD当前指向最新提交。否则,您可以使用

git diff origin/master..master

(当然,如果你的远程并非origin,或者你的分支不是master,请相应地进行更改。)


9

git log -p --branches --not --remotes

执行成功。


3
如果在你上次拉取代码后,远程分支没有其他的提交,那么git diff origin/master..HEAD就能正常运行。这种解决方案适用于无论远程分支是否活跃的情况。仅出于这个原因,我更喜欢使用这种方法来查看本地还未推送的提交差异。 - bluehazetech

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接