简体   繁体   English

使用Xcode 4作为Git difftool

[英]Use Xcode 4 as Git difftool

I want to use Xcode 4's "Version Editor" view as my standard difftool for Git. 我想使用Xcode 4的“版本编辑器”视图作为Git的标准difftool。

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). 并且在Xcode的diff查看器中打开diff(因为它很酷)。

Is this possible? 这可能吗? How? 怎么样?

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: 我猜你已经知道了以下内容,但是为了其他人的利益,你可以使用Apple的FileMerge应用程序,而不是使用类似的命令来获得类似的,尽管稍微有点经验:

git difftool path/to/file

My git defaults to using FileMerge as the difftool, but you can configure it explicitly with: 我的git默认使用FileMerge作为difftool,但您可以使用以下命令显式配置它:

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每次都列出候选工具。)我也想禁用git的difftool预启动提示:

git config --global difftool.prompt false

It is possible to configure git so that git diff will invoke FileMerge as well, or instead. 可以配置git,以便git diff也可以调用FileMerge,或者代之以。 (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 : (我更喜欢以我自己的方式离开git diff 。)如果你想要,你首先需要创建一个shell脚本来将适当的参数映射到opendiff

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

and then run 然后跑

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM