如何将 p4merge 设置为 Visual Studio 2015 的 diff 工具 | git

How to set up p4merge as diff tool for Visual Studio 2015 | git

我已经通过 this 教程成功地将 P4Merge 与 TortoiseGit 连接起来。

但是,鉴于我大部分时间都花在 IDE(Visual Studio 2015 年)上,我还想将其设置为使用 P4Merge 作为差异工具。

以前(也就是在使用 TFS 时),this 就足够了。但是,考虑到我现在使用的是 git,VS 中没有这样连接的选项:

但是,我发现 how 通过 Visual Studio 2015 工具开发人员命令提示 tf diff /configure 配置用户工具,继续在上一个教程中使用 .bat 文件,但它似乎对我没有任何作用。

我可能遗漏了一些东西,但希望鉴于 P4Merge、VS (& git) 如今的流行程度,现在必须有人已经设法实现了这一目标。

我假设您已将 P4Merge 安装在默认安装目录中,如果没有,请在下面列出的命令中相应地编辑目录。

在命令行中执行这些命令以将 Git 的默认 mergetool 和 difftool 设置为 P4Merge。

git config --global merge.tool p4merge
git config --global mergetool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"
git config --global diff.tool p4merge
git config --global difftool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"

之后,每当启动 git difftool 时,它都会启动 p4merge。

但是,在存储库级别仍然可以有一个设置覆盖全局设置,它位于 .git/config 您可以手动编辑配置文件,也可以打开命令行,将目录更改为存储库并使用以下命令更改默认的合并和差异工具。

git config --local merge.tool p4merge
git config --local mergetool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"
git config --local diff.tool p4merge
git config --local difftool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"