git show commit 无法比较

发布于 2024-12-06 03:13:01 字数 335 浏览 7 评论 0原文

我希望在通过 git show 查看时在 Beyond Compare 或任何其他单独的 diff 工具中看到特定的提交。我尝试查看 git show/difftool/config 的帮助,但找不到任何内容。有谁知道如何做到这一点?

我查看了 Git Diff 与 Beyond Compare 并为 配置了 Beyond Compare git difftool 但我也想将它用作 git show 中的工具

I would like to see a specific commit in Beyond Compare or any other separate diff tool while viewing it via git show. I tried looking at help of git show/difftool/config but couldn't find anything. Does anyone know how it can be done?

I've looked at Git Diff with Beyond Compare and configured Beyond Compare for git difftool but I also want to use it as tool from git show

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

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

发布评论

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

评论(6

影子是时光的心 2024-12-13 03:13:01

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

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

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

I managed to use git difftool to see commits that I normally used to see via git show.

git show $commit translates to git difftool $commit^ $commit.

The above command shows difference between commit's parent ($commit^) and commit. All this is of course after configuring Beyond Compare with difftool.

梦罢 2024-12-13 03:13:01

您还可以创建一个别名“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

You can also create an alias "showtool" to wrap the call to 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' -"

.. then you can execute:

git showtool 81e945b

.. or just

git showtool

.. as a shortcut for git difftool 81e945b~1 81e945b to show the changes introduced in 81e945b using the configured difftool, or in the second case git difftool HEAD~1 HEAD

永言不败 2024-12-13 03:13:01

一旦你设置了 diff 工具,比如很棒的 p4merge,你就可以做到这一点:

git diff HEAD HEAD~1

工作起来就像一个魅力。

同样,如果你想查看之前的提交,你可以这样做:

git diff HEAD~1 HEAD~2

Once you have a diff tool set up, like the awesome p4merge, you can do this:

git diff HEAD HEAD~1

Works like a charm.

Similarly if you want to see the commit before that, you can do:

git diff HEAD~1 HEAD~2
不回头走下去 2024-12-13 03:13:01

这对我很有用,可以显示上次提交的差异

git difftool HEAD~ HEAD

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

git difftool 1234ABCD~ 1234ABCD

This worked for me nicely, to show the diff of the last commit

git difftool HEAD~ HEAD

For other commits you can replace HEAD with commit hash eg:

git difftool 1234ABCD~ 1234ABCD
じее 2024-12-13 03:13:01

我认为 git show 是基于 GIT_PAGER 变量中设置的工具。我不使用Beyond Compare,但我认为您可以尝试这样的操作:

$ GIT_PAGER='bc3' git show <whatever>

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

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

I think that git show is based on the tool set in the GIT_PAGER variable. I don't use Beyond Compare but i think that you can try something like this:

$ GIT_PAGER='bc3' git show <whatever>

Maybe you should fill the GIT_PAGER variable with some additional parameter that allows bc3 process the input.

There are more suitable ways to persist the pager. This question can give you more tips about how to do it.

五里雾 2024-12-13 03:13:01

基于@javabrett的回答,我创建了

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

支持类似命令

$ git showtool -y :/my\ commit\ message

Based on @javabrett answer I have created

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

to support commands like

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