MSYS的Git合并工具命令选项问题 [英] Msys Git Merge Tool Command Options Issue
问题描述
我使用 MSYS的Git 以在Windows机器上的源代码控制,我想弄清楚如何让我的合并工具,的WinMerge ,使用Git工作。
我已经按照在这个博客的说明,以尽我最大的能力,因为它是我发现我想要做的最接近的一次。基本上我所做的是:
修改我的的.gitconfig
文件包括以下内容:
[合并]
工具=的WinMerge[合并工具的WinMerge]
CMD = \\C:\\\\ Program Files文件(x86)的\\\\ \\\\的WinMerge WinMergeU.exe \\$ PWD / $ LOCAL$ PWD / $ REMOTE$ PWD / $合并的
trustExit code =假
keepBackup = FALSE
这几乎是工作。当我尝试从Git的合并工具,的WinMerge给我一个错误说,它不能找到文件,这使得完全有道理的,因为它正在寻找的路径是的路径:
C:\\我的\\工作\\目录\\ -e
C:\\我的\\工作\\目录\\ -UB
看起来Git是传球选择到合并工具,而不是本地和放大器;我期望远程文件名获得通过,如果一切都正常工作。
我在网上搜索了Git的合并文档,但我似乎无法找到与我尝试做任何事情。我的猜测是,该解决方案将是下列之一:
- 更改
$ LOCAL
&安培;$ REMOTE
变量,以正确的价值观,假定$ LOCAL
&安培;$ REMOTE
是不正确的。 - 写
的.bat
脚本到我的蝙蝠逻辑中调用WinMergeU,并处理这些参数的Git发送到合并工具code>脚本。
CMD = \\C:\\\\ Program Files文件(x86)的\\\\ \\\\的WinMerge WinMergeU.exe / UB / E \\
CMD = \\C:\\\\ Program Files文件(x86)的\\\\ \\\\的WinMerge WinMergeU.exe / U / E \\
(/ u是新/ UB与最新的WinMerge)
可能会在合并工具部分的工作更好地为命令。
但是,您可能必须包装在脚本此调用,如本<一个描述href=\"http://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-visual-diff-program/392899#392899\">SO回答。
适用于提取 merge.tool
:
配置
合并工具
与您的自定义实际情况差异
工具:
块引用>C:\\ myGitRepo&GT;混帐配置--global merge.tool的WinMerge
C:\\ myGitRepo&GT;混帐配置--global mergetool.winmerge.cmdwinmerge.sh \\$ LOCAL \\\\$远程\\
C:\\ myGitRepo&GT;混帐配置--global mergetool.prompt假使用
winmerge.sh
存储在您的路径的目录部分
:#!/ bin / sh的
呼应启动WinMergeU.exe:$ 1 $ 2
C:/ Program Files文件/的WinMerge / WinMergeU.exe-e -UB$ 1$ 2
如果您有其他工具(
kdiff3
,P4Diff
,...),创建另一个shell脚本,相应的mergetool.myMergeTool.cmd
配置指令。结果
然后你就可以轻松切换工具与merge.tool
配置。
块引用>I'm using msys Git for source control on a Windows machine and I'm trying to figure out how to get my merge tool, WinMerge, to work with Git.
I've followed the instructions on this blog to the best of my ability since it's the closest I've found to what I'm trying to do. Basically what I did was:
Modify my
.gitconfig
file to include the following:[merge] tool = winmerge [mergetool "winmerge"] cmd = \"C:\\Program Files (x86)\\WinMerge\\WinMergeU.exe\" "$PWD/$LOCAL" "$PWD/$REMOTE" "$PWD/$MERGED" trustExitCode = false keepBackup = falseThis is almost working. When I try to run the merge tool from Git, WinMerge gives me an error saying it can't find the paths of the files, which makes complete sense since the paths it is looking for are:
C:\MY\WORKING\DIRECTORY\-e C:\MY\WORKING\DIRECTORY\-ubIt looks like Git is passing options into the merge tool instead of the local & remote file names that I would expect to get passed if everything was working correctly.
I've searched online for Git's merge documentation, but I can't seem to find anything related to what I'm trying to do. My guess is that the solution will be one of the following:
- Change the
$LOCAL
&$REMOTE
variables to the correct values, assuming$LOCAL
&$REMOTE
are incorrect.- Write a
.bat
script to call WinMergeU, and handle the arguments Git sends to the merge tool within the logic of my.bat
script.
解决方案From WinMerge Command line manual:
cmd = \"C:\\Program Files (x86)\\WinMerge\\WinMergeU.exe /ub /e \" cmd = \"C:\\Program Files (x86)\\WinMerge\\WinMergeU.exe /u /e \"
(/u is the new /ub with latest WinMerge)
might work better as a command in your mergetool section.
However, you might have to wrap this call in a script, as described in this SO answer.
Extract adapted to
merge.tool
:Practical case for configuring
mergetool
with your customdiff
tool:
C:\myGitRepo>git config --global merge.tool winmerge C:\myGitRepo>git config --global mergetool.winmerge.cmd "winmerge.sh \"$LOCAL\" \"$REMOTE\"" C:\myGitRepo>git config --global mergetool.prompt false
With
winmerge.sh
stored in a directory part of yourPATH
:#!/bin/sh echo Launching WinMergeU.exe: $1 $2 "C:/Program Files/WinMerge/WinMergeU.exe" -e -ub "$1" "$2"
If you have another tool (
kdiff3
,P4Diff
, ...), create another shell script, and the appropriatemergetool.myMergeTool.cmd
config directive.
Then you can easily switch tools with themerge.tool
config.
这篇关于MSYS的Git合并工具命令选项问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!