21

我想在 Beyond Compare 或任何其他单独的差异工具中查看特定提交,同时通过git show. 我尝试查看 git show/difftool/config 的帮助,但找不到任何东西。有谁知道怎么做?

我已经查看了带有 Beyond Compare 的 Git Diff并配置了 Beyond Compare ,git difftool但我也想将它用作工具git show

4

6 回答 6

23

我设法用来git difftool查看我通常通过git show.

git show $commit转换为git difftool $commit^ $commit

上面的命令显示了提交的父级 ($commit^) 和提交之间的区别。这一切当然是在使用 difftool 配置 Beyond Compare 之后。

于 2011-10-06T12:06:26.080 回答
12

您还可以创建一个别名“showtool”来包装对以下的调用git difftool

set +o histexpand
git config --global alias.showtool "!sh -c 'if [ -z \$1 ]; then REVISION="HEAD"; else REVISION="\$1"; fi; git difftool \$REVISION~ \$REVISION' -"

..然后你可以执行:

git showtool 81e945b

.. 要不就

git showtool

.. 作为显示使用配置的 difftool 或在第二种情况下git difftool 81e945b~1 81e945b引入的更改的快捷方式81e945bgit difftool HEAD~1 HEAD

于 2013-08-20T01:36:56.787 回答
3

一旦你设置了一个差异工具,比如很棒的 p4merge,你可以这样做:

git diff HEAD HEAD~1

奇迹般有效。

同样,如果您想在此之前查看提交,您可以执行以下操作:

git diff HEAD~1 HEAD~2
于 2014-08-25T04:03:02.287 回答
1

这对我很有效,可以显示最后一次提交的差异

git difftool HEAD~ HEAD

对于其他提交,您可以HEAD用提交哈希替换,例如:

git difftool 1234ABCD~ 1234ABCD
于 2013-07-16T19:38:51.060 回答
0

我认为 git show 是基于 GIT_PAGER 变量中的工具集。我不使用 Beyond Compare,但我认为你可以尝试这样的事情:

$ GIT_PAGER='bc3' git show <whatever>

也许您应该使用一些允许 bc3 处理输入的附加参数填充 GIT_PAGER 变量。

有更合适的方法来持久化寻呼机。这个问题可以为您提供有关如何操作的更多提示。

于 2011-09-22T14:13:36.727 回答
0

基于我创建的@javabrett 答案

https://github.com/albfan/git-showtool

支持类似的命令

$ git showtool -y :/my\ commit\ message
于 2014-12-28T19:43:47.100 回答