windows 如何将 Araxis 设置为 MSYS git 的差异/合并工具?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/825478/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set Araxis as diff / merge tool for MSYS git?
提问by joce
I'm trying to use Araxis Mergeas my diff / merge tool for MSYSGit.
我正在尝试使用Araxis Merge作为MSYSGit 的差异/合并工具。
I found a few resources on the net:
我在网上找到了一些资源:
- On the Araxis site, they mention an "easy" way, but it implies a executables (araxisgitdiff.exe and araxisgitmerge.exe) that are not part of my distro.
- I also found some info in gitguru, but the actual information re: Araxis is sparse at best, and I could not make anything out of that.
- Finally, there was some info on an older stackoverflow post, but the suggested method doesn't work for me. That particular info was geared towards OS X. I "translated" to Windows as best as I could, but without success:
- 在Araxis 网站上,他们提到了一种“简单”的方式,但它暗示了一个不属于我的发行版的可执行文件(araxisgitdiff.exe 和 araxisgitmerge.exe)。
- 我还在gitguru 中找到了一些信息,但实际信息是:Araxis 充其量是稀疏的,我无法从中做出任何事情。
- 最后,在较旧的stackoverflow 帖子上有一些信息,但建议的方法对我不起作用。该特定信息面向 OS X。我尽我所能“翻译”到 Windows,但没有成功:
I created /bin/git-diff-driver.sh
我创建 /bin/git-diff-driver.sh
#!/bin/sh
"/c/Program Files/Araxis/Araxis Merge/compare.exe" -title1:" (repo version)" -title2:" " -max "" ""
and edited gitconfig
和编辑 gitconfig
[merge]
tool = araxismerge
[mergetool "araxismerge"]
cmd = "/c/Program Files/Araxis/Araxis Merge/compare.exe" -3 -merge -wait $LOCAL $BASE $REMOTE $MERGED
[diff]
external = "/bin/git-diff-driver.sh"
and the only result I get is:
我得到的唯一结果是:
$ git diff HEAD^ HEAD
external diff died, stopping at PowerEditor/src/Notepad_plus.cpp.
$ git diff HEAD^ HEAD
外部差异死了,停在 PowerEditor/src/Notepad_plus.cpp。
Edit:
编辑:
I've also tried with the exe named as "c:/Program Files/Araxis/Araxis Merge/compare.exe"
as suggested by one of the answers, with the same results.
我也尝试过"c:/Program Files/Araxis/Araxis Merge/compare.exe"
按照其中一个答案的建议命名的 exe ,结果相同。
Edit:
编辑:
I've found that it can easily be set if you use TortoiseGit, but it seems to handle diff by itself and no settings from TortoiseGit give any indication on how to set up Araxis as a merge tool when diff is invoked from the command line.
我发现如果您使用 TortoiseGit,它可以很容易地设置,但它似乎自己处理 diff,并且 TortoiseGit 中的任何设置都没有给出任何指示当从命令行调用 diff 时如何将 Araxis 设置为合并工具。
Edit:
编辑:
So, the question is: Is there anybody who successfully uses Araxis Merge to diff and merge stuff with MSYSGit, and if so, how do you it?
所以,问题是:有没有人成功地使用 Araxis Merge 将东西与 MSYSGit 进行差异和合并,如果是这样,你是怎么做的?
回答by Thell
If you want to have 'git diff' always use araxis you can use the instructions in the help file, but if you want to have control to use 'git diff' as you normally would from the command line and 'git difftool' to engage the Araxis GUI.
如果你想让 'git diff' 总是使用 araxis 你可以使用帮助文件中的说明,但是如果你想像往常一样从命令行控制使用 'git diff' 和 'git difftool' 来参与Araxis GUI。
Try adding the following to your git config::
尝试将以下内容添加到您的 git 配置中:
[difftool "araxis"]
path = "/c/Program Files/Araxis/Araxis Merge/compare.exe"
renames = true
trustExitCode = true
[diff]
tool = araxis
stat = true
[mergetool "araxismergetool"]
cmd = 'C:\Program Files\Araxis\Araxis Merge\araxisgitmerge.exe' "$REMOTE" "$BASE" "$PWD/$LOCAL" "$PWD/$MERGED"
trustExitCode = false
[mergetool]
keepBackup = false
[merge]
tool = araxismergetool
stat = true
回答by eckes
The documentation at araxis has been updated: http://www.araxis.com/merge/documentation-windows/integrating-with-other-applications#Git
araxis 的文档已更新:http: //www.araxis.com/merge/documentation-windows/integrating-with-other-applications#Git
I can use the configuration shown there without any modifications.
我可以使用那里显示的配置而无需任何修改。
回答by VonC
Right... I got it working, with msysgit version 1.6.3.2.1299.gee46c, under DOS or Git Bash, with an evaluation license for Araxis Merge 2009, v2009.3713:
是的...我在 DOS 或 Git Bash 下使用 msysgit 版本 1.6.3.2.1299.gee46c 运行,并获得了 Araxis Merge 2009, v2009.3713 的评估许可证:
The approach is to use the new git difftool
and git mergetool
, instead of plain diff.
方法是使用新的git difftool
和git mergetool
,而不是普通的差异。
First, let's setup some scripts for those diff and merge tool
首先,让我们为那些差异和合并工具设置一些脚本
C:\>git config --global diff.tool adifftool
C:\>git config --global diff.external git-difftool--helper
C:\>git config --global difftool.adifftool.cmd "difftool.sh \"$LOCAL\" \"$REMOTE\" \"$MERGED\""
C:\>git config --global difftool.prompt false
Notes:
笔记:
- by setting diff.external to the Git script
git-difftool--helper
, I will use difftool even when I will type 'git diff
'. - do not forget to pass
$MERGED
to your difftool script: that is the only variable with the real name of the file being diff'ed.$LOCAL
and$REMOTE
are temporary names.
- 通过将 diff.external 设置为 Git 脚本
git-difftool--helper
,即使我将键入“git diff
” ,我也会使用 difftool 。 - 不要忘记传递
$MERGED
给您的 difftool 脚本:这是唯一一个具有被 diff 文件真实名称的变量。$LOCAL
和$REMOTE
是临时名称。
For the merge tool, you would set the following global values:
对于合并工具,您将设置以下全局值:
C:\>git config --global merge.tool amergetool
C:\>git config --global mergetool.amergetool.cmd "mergetool.sh \"$PWD/$LOCAL\" \"$PWD/$BASE\" \"$PWD/$REMOTE\" \"$PWD/$MERGED\""
C:\>git config --global mergetool.prompt false
By setting those tools to some shell scripts, you will be able to switch tools from within those scripts.
Another approach is to name your tools (mergetool.araxis.cmd
, mergetool.winmerge.cmd
, ...) and to specify the right tool in the diff.tool
or merge.tool
setting.
通过将这些工具设置为某些 shell 脚本,您将能够从这些脚本中切换工具。
另一种方法是命名您的工具(mergetool.araxis.cmd
, mergetool.winmerge.cmd
, ...)并在diff.tool
或merge.tool
设置中指定正确的工具。
Create difftool.sh
and mergetool.sh
in a directory referenced by your global environment variable PATH
. They will work even from DOS (and they are sh
-- shell -- scripts)
在全局环境变量引用的目录中创建difftool.sh
和。它们甚至可以在 DOS 下工作(它们是-- shell -- 脚本)mergetool.sh
PATH
sh
difftool.sh
difftool.sh
#!/bin/sh
echo Launching Araxis Merge.exe:
t1="' (from)'"
t2="'(to)'"
"C:/Program Files/Araxis/Araxis Merge/Compare.exe" -max -nowait -2 -title1:${t1} -title2:${t2} "" ""
Notes:
笔记:
Impossible to have -title1:"someTitle With Space"... only title without space does work..., so for now, try it without any 'titleN
' option.
Got it! You cannot pass the title value directly to the-title
option, you need to set it to a local variable, with"' '"
quotes combinations (the double quotes will disappear during the shell script execution, leaving the simple quotes, allowing spaces within a title!)$3
represent the real name and not some temporary file name for diff purpose. Hence the use of$3
within thetitle1
option, with space in it.git diff HEAD^ HEAD
would not work in DOS session: onlygit diff "HEAD^" HEAD
would.
不可能有 -title1:"someTitle With Space"......只有没有空格的标题才有效......所以现在,尝试不带任何 'titleN
' 选项。
知道了!您不能将标题值直接传递给-title
选项,您需要将其设置为局部变量,带"' '"
引号组合(在 shell 脚本执行过程中双引号将消失,留下简单的引号,标题中允许有空格!)$3
代表真实名称而不是一些用于差异目的的临时文件名。因此$3
在title1
选项内使用,其中有空间。git diff HEAD^ HEAD
不会在 DOS 会话中工作:只会git diff "HEAD^" HEAD
。
mergetool.sh
合并工具
#!/bin/sh
# Passing the following parameters to mergetool:
# local base remote merge_result
alocal=
base=
remote=
result=
t1="' (current branch)'"
t2="'(common ancestor)'"
t3="'(to be merged)'"
if [ -f $base ]
then
"C:/Program Files/Araxis/Araxis Merge/Compare.exe" -max -wait -merge -3 -a2 -title1:${t1} -title2:${t2} -title3:${t3} "$alocal" "$base" "$remote" "$result"
else
"C:/Program Files/Araxis/Araxis Merge/Compare.exe" -max -wait -merge -3 -a2 -title1:${t1} -title2:${t2} -title3:${t3} "$alocal" "$result" "$remote" "$result"
fi
I am not sure I those scripts do work properly when multiple files are involved (multiple diffs, multiple files to be merged).
Just tested it: it works, and Araxis compare.exe does open one tab per file to diff or merge.
Give it a try and let us know ;)
当涉及多个文件(多个差异,要合并的多个文件)时,我不确定这些脚本是否能正常工作。
刚刚测试了它:它有效,并且 Araxis compare.exe 确实为每个文件打开一个选项卡以进行差异或合并。
试一试,让我们知道;)
回答by CB Bailey
I think that you need to be a bit more careful with your escaping in your .gitconfig.
我认为在 .gitconfig 中进行转义时需要更加小心。
Unfortunately, due to the way the config variable is expanded and evaled, your string needs to be an valid shell command which is then 'git config' escaped.
不幸的是,由于 config 变量的扩展和评估方式,您的字符串需要是一个有效的 shell 命令,然后 'git config' 转义。
Try something like this:
尝试这样的事情:
[mergetool "araxismerge"]
cmd = \"/c/Program Files/Araxis/Araxis Merge/compare.exe\" -3 -merge -wait \"$LOCAL\" \"$BASE\" \"$REMOTE\" \"$MERGED\"
Yes, not very pretty, I know. It's one of the cases where using git config
directly is actually easier.
是的,不是很漂亮,我知道。这是git config
直接使用实际上更容易的情况之一。
git config --global mergetool.araxismerge.cmd '"/c/Program Files/Araxis/Araxis Merge/compare.exe" -3 -merge -wait "$LOCAL" "$BASE" "$REMOTE" "$MERGED"'
回答by nightingale
I struggled with this problem for quite a while, and now I finally can say, that all suggested dirty hacks (like intermediate shell scripts) are rather unnecessary =D. Thing is, all of the latest versions of MSYSGit (I have 1.6.4) support Araxis Merge (I have 2008) out of the box. It comes at no surprise, that internally it's called "araxis". So, all that you need is to set
我在这个问题上挣扎了很长一段时间,现在我终于可以说,所有建议的脏黑客(如中间 shell 脚本)都是不必要的 =D。事实是,所有最新版本的 MSYSGit(我有 1.6.4)都支持开箱即用的 Araxis Merge(我有 2008)。毫不奇怪,它在内部被称为“araxis”。所以,你只需要设置
[merge]
tool = araxis
in your .gitconfig
. Also you have to include Araxis folder into your PATH environment variable (MSYSGit looks for Compare.exe
).
在您的.gitconfig
. 此外,您还必须将 Araxis 文件夹包含到您的 PATH 环境变量中(MSYSGit 查找Compare.exe
)。
For a good measure, other Git settings related to "araxis" mergetool, that you could have configured (especially, if you happen to choose exactly that name, as did some people on this page), should all be removed. That includes everything under [mergetool "araxis"]
section. Be sure to remove them from all configs (system, global, and repository), otherwise, they might interfere with normal "internal tool" behavior.
作为一个很好的衡量标准,您可以配置的与“araxis”合并工具相关的其他 Git 设置(特别是,如果您恰好选择了该名称,就像本页面上的某些人所做的那样),都应该被删除。这包括[mergetool "araxis"]
部分下的所有内容。确保从所有配置(系统、全局和存储库)中删除它们,否则,它们可能会干扰正常的“内部工具”行为。
In any case, if you're interested in how MSYSGit will start your Araxis Merge, or wondering what other mergetools it supports out of the box, the place to look is \share\git-gui\lib\mergetool.tcl
script in your MSYSGit installation folder.
在任何情况下,如果您对 MSYSGit 将如何启动 Araxis Merge 感兴趣,或者想知道它支持哪些开箱即用的其他合并工具,\share\git-gui\lib\mergetool.tcl
请查看 MSYSGit 安装文件夹中的脚本。
PS. You might be able to avoid setting PATH environment variable, by configuring mergetool.araxis.path
in .gitconfig
. Personally, I never bothered to do so, since
附注。您可以通过mergetool.araxis.path
在.gitconfig
. 就个人而言,我从不费心这样做,因为
- I use Araxis Merge from command line anyway.
- Specifying directory path in
.gitconfig
(especially the one like"C:\Program Files\Araxis\Araxis Merge\"
, which contains spaces) can prove hard to be done correctly, since it is prone to backslash/forwardslash issues, that plague MSYSGit.
- 无论如何,我从命令行使用 Araxis Merge。
- 指定目录路径
.gitconfig
(尤其是"C:\Program Files\Araxis\Araxis Merge\"
包含空格的 .
PPS. All of the above applies to making Araxis your difftool, too. I.e, you need to add
聚苯乙烯。以上所有内容也适用于使 Araxis 成为您的 difftool。即,您需要添加
[diff]
tool = araxis
and remove anything else in [difftool "araxis"]
section, if you have it in your config (don't forget to set up PATH, though).
并删除[difftool "araxis"]
部分中的任何其他内容,如果您的配置中有它(但不要忘记设置 PATH)。
回答by joce
One way I found to do it "simply" is to install TortoiseGitand set the diff / merge tools in TortoiseGit options.
However, this does not address the issue if you want to diff from the command line.
我发现“简单”的一种方法是安装TortoiseGit并在 TortoiseGit 选项中设置差异/合并工具。
但是,如果您想从命令行进行区分,这并不能解决问题。
回答by Rutger Nijlunsing
Since I've been bitten to customised git differs/mergers, I thought I would try to fix this one for once and for all. I got to the point where AraxisMerge started, but without the titles of the tabs. So that will be left as an exercise for the reader :)
由于我一直被定制的 git 差异/合并所困扰,我想我会尝试一劳永逸地解决这个问题。我到了 AraxisMerge 开始的地方,但没有标签的标题。所以这将留给读者作为练习:)
Observations and comments:
观察和评论:
- I didn't have AraxisMerge, so I downloaded it and got a free 30-days evaluation license to try it out with. This version (7.0 it seems) comes with araxisgitdiff.exe, and the link with instructions you send works. So that would be option #1: upgrade araxis merge.
- Since I'm working from CMD.EXE, 'git diff HEAD HEAD^' does not work. The '^' needs to be escaped to 'git diff HEAD "HEAD^"'.
- For my own work I use kdiff3 as a free replacement on Windows which works reasonably well (it helps that it is supported by default by git)
- 我没有 AraxisMerge,所以我下载了它并获得了 30 天的免费评估许可证来试用它。此版本(似乎是 7.0)带有 araxisgitdiff.exe,并且您发送的说明链接有效。所以这将是选项 #1:升级 araxis 合并。
- 由于我正在使用 CMD.EXE,因此 'git diff HEAD HEAD^' 不起作用。'^' 需要转义为 'git diff HEAD "HEAD^"'。
- 对于我自己的工作,我使用 kdiff3 作为 Windows 上的免费替代品,它运行得相当好(git 默认支持它有助于)
Starting with the git-diff-driver.sh gave the same error to me. After changing the script to only contain 'echo', this did not change. So the error is independent from the contents of the script.
从 git-diff-driver.sh 开始给了我同样的错误。将脚本更改为仅包含“echo”后,这并没有改变。所以错误与脚本的内容无关。
Then I removed the '/bin' part from .gitconfig, so the line becomes
然后我从 .gitconfig 中删除了“/bin”部分,因此该行变为
external = "git-diff-driver.sh"
...and this started to work: it started the merger, but it does not escape the '(repo) ' part correctly. As a workaround I got it working without the titles with:
...这开始起作用了:它开始了合并,但它没有正确地逃脱 '(repo) ' 部分。作为一种解决方法,我让它在没有标题的情况下工作:
#!/bin/sh
"/c/Program Files/Araxis/Araxis Merge/compare.exe" -max "" ""
Good luck!
祝你好运!
回答by VonC
You could try to follow the script mentioned in my answer about diffMerge(for Windows) and see if it works.
您可以尝试按照我在关于 diffMerge(适用于 Windows)的回答中提到的脚本,看看它是否有效。
The executable path could be better expressed with:
可执行路径可以更好地表示为:
#!/bin/sh
"C:/Program Files/Araxis/Araxis Merge/compare.exe" -title1:" (repo version)" -title2:" " -max "" ""