使用 Xcode 4 作为 Git difftool

发布于 2024-12-15 15:49:02 字数 209 浏览 6 评论 0原文

我想使用 Xcode 4 的“版本编辑器”视图作为 Git 的标准 diff 工具。

换句话说,我希望能够设置此选项:

git config --global diff.external <XCODE>

并在 Xcode 的 diff 查看器中打开 diff(因为它很酷)。

这可能吗?如何?

I want to use Xcode 4's "Version Editor" view as my standard difftool for Git.

In other words, I want to be able to set this option:

git config --global diff.external <XCODE>

And have the diff open in Xcode's diff viewer (because it's cool).

Is this possible? How?

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

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

发布评论

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

评论(1

南薇 2024-12-22 15:49:03

遗憾的是不可能。不过,我们还是希望苹果有一天能够改变这一现状。

我猜您已经知道以下内容,但为了其他可能不知道的人的利益,您可以使用 Apple 的 FileMerge 应用程序来获得类似的(尽管稍微少一些)命令体验,例如:

git difftool path/to/file

我的 git 默认使用 FileMerge 作为 difftool ,但你可以显式配置它:(

git config --global diff.tool opendiff

这也会阻止 git 每次列出候选工具。)我还喜欢禁用 git 的 difftool 预启动提示:

git config --global difftool.prompt false

可以配置 git,以便git diff 也会调用 FileMerge,或者改为调用 FileMerge。 (我更喜欢让 git diff 保持原样。)如果您愿意,您首先需要创建一个 shell 脚本来将适当的参数映射到 opendiff

#!/bin/sh
/usr/bin/opendiff "$2" "$5" -merge "$1"

:然后运行

git config --global diff.external /path/to/shell/script

Sadly not possible. Here's hoping Apple changes that someday though.

I'm guessing you already know the following, but for the benefit of others who may not, you can use Apple's FileMerge application instead for a similar, albeit somewhat lesser, experience with a command like:

git difftool path/to/file

My git defaults to using FileMerge as the difftool, but you can configure it explicitly with:

git config --global diff.tool opendiff

(This stops git from listing the candidate tools every time too.) I also like to disable git's difftool pre-launch prompting:

git config --global difftool.prompt false

It is possible to configure git so that git diff will invoke FileMerge as well, or instead. (I prefer to just leave git diff the way it is myself.) If you want that you first need to create a shell script to map the appropriate arguments to opendiff:

#!/bin/sh
/usr/bin/opendiff "$2" "$5" -merge "$1"

and then run

git config --global diff.external /path/to/shell/script
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文