【问题标题】:View git changes/diffs of local commits not pushed to remote查看未推送到远程的本地提交的 git 更改/差异
【发布时间】:2012-09-17 13:41:24
【问题描述】:

我在本地提交了三个 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

感谢您的帮助。

【问题讨论】:

  • 如果您想查看每次提交的差异,请使用git log -p --branches --not --remotes-p 代表补丁。它会显示每个提交的统一差异。

标签: git git-commit git-log


【解决方案1】:

你可以像这样使用 git diff:

git diff origin/master..HEAD

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

git diff origin/master..master

(当然,如果您的远程不是原始分支,或者您的分支不是主分支,请相应更改。)

【讨论】:

    【解决方案2】:

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

    工作。

    【讨论】:

    • git diff origin/master..HEAD 在您上次获取后没有任何其他提交到远程分支的情况下有效。无论远程分支上的活动如何,此解决方案都有效。仅出于这个原因,我更喜欢这种方法来查看尚未推送的本地提交的差异。
    猜你喜欢
    • 2011-01-02
    • 2015-08-16
    • 2018-03-04
    • 2022-06-11
    • 2013-02-24
    • 2013-04-25
    • 2013-08-31
    • 2016-06-27
    • 2013-04-08
    相关资源
    最近更新 更多