git show commit超越比较

时间:2011-09-22 13:06:50

标签: git beyondcompare git-diff

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

我查看Git Diff with Beyond Compare并为git difftool配置了Beyond Compare,但我也希望将其用作git show的工具

6 个答案:

答案 0 :(得分:23)

我设法使用git difftool查看我通常通过git show看到的提交。

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

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

答案 1 :(得分: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

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

答案 2 :(得分:3)

一旦你设置了差异工具,就像真棒p4merge一样,你可以这样做:

git diff HEAD HEAD~1

像魅力一样工作。

同样,如果你想在此之前看到提交,你可以这样做:

git diff HEAD~1 HEAD~2

答案 3 :(得分:1)

这很适合我,以显示最后一次提交的差异

git difftool HEAD~ HEAD

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

git difftool 1234ABCD~ 1234ABCD

答案 4 :(得分:0)

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

$ GIT_PAGER='bc3' git show <whatever>

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

有更合适的方法来保留寻呼机。 This question可以为您提供有关如何操作的更多提示。

答案 5 :(得分:0)

根据@javabrett的回答我创建了

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

支持

等命令
$ git showtool -y :/my\ commit\ message
相关问题