如何将 Winmerge 与 Git 扩展一起使用?
我正在使用 Git 扩展,它预安装并设置 KDiff 作为 diff 工具解决合并冲突。不过我非常喜欢 Winmerge,并且想用 Winmerge 替换 KDiff。
在 Git 扩展设置中,有一些设置可以更改合并工具,但我似乎无法弄清楚应该使用什么语法以及原因。似乎有 4 个变量:$BASE、$LOCAL、$REMOTE、$MERGED。看来我应该将这些传递给 WinMergeU.exe,但是使用哪些命令行参数?
我曾多次尝试搜索此问题,但似乎没有真正有效的答案。
I'm using Git Extensions and it pre-installs and sets up KDiff as the diff tool to solve merge conflicts. I'm very fond of Winmerge though and would like to replace KDiff with Winmerge.
In the Git Extensions settings, there are settings to change the Mergetool, but I can't seem to figure out what syntax I should use and why. There seem to be 4 variables: $BASE, $LOCAL, $REMOTE, $MERGED. It seems that I should pass these to WinMergeU.exe, but with which command line parameters?
I've tried to search for this a few times, but there is no answer that actually seems to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
概述
以下是有关如何设置 GIT 版本控制的说明,以便您可以使用比默认安装更好的工具集。该安装要求已安装 GIT 扩展并涉及在 GIT 扩展中配置 Winmerge。
安装
完成所有提示并安装在 Winmerge 的默认目录中。
在 GIT 版本控制中配置 Winmerge
在文本编辑器中打开一个新文档。
复制/粘贴以下内容并将文档另存为“wMerge.sh”到“C:\Program Files (x86)\Git\bin\”目录。
转到“用户->用户名”目录并找到 .gitconfig 文件。在您喜欢的编辑器中打开它,复制/粘贴以下代码并保存:
运行“GitExtensions”,转到“工具->设置->Git Extensions->Git Config”。如果您已正确完成安装并将工具引用到其目录,则您的全局设置页面应如下所示(注意:请在姓名和电子邮件中填写您的姓名):
合并工具:
winmerge
mergetool 的路径:
c:/Program Files (x86)/winmerge/winmergeu.exe
合并工具命令:
wMerge.sh "$MERGED" "$REMOTE"
difftool:
winmerge
difftool 的路径:
c:/Program Files (x86)/winmerge/winmergeu.exe
difftool 命令:
"c:/Program Files (x86)/winmerge/winmergeu.exe" "$LOCAL" "$REMOTE"
行结尾:按原样签出,按原样提交
导航到清单选项卡以验证 GIT 是否全部“绿色”并且对您的设置感到满意。
Overview
The following is instructions on how to setup GIT Version Control so that you can use a better set of tools than the default installation. The setup requires that GIT Extensions is already installed and involves configuring Winmerge in GIT extensions.
Installation
Walk through all the prompts and install in the default directory for Winmerge.
Configure Winmerge in GIT Version Control
Open a new doc in a text editor.
Copy/paste the following and save the document as "wMerge.sh" to your "C:\Program Files (x86)\Git\bin\" directory.
Goto your "Users->username" directory and locate the .gitconfig file. Open it in your favorite editor copy/paste the following code and Save:
Run "GitExtensions", goto "tools->Settings->Git Extensions->Git Config". If you've done your installation properly and referenced the tools to their directory, your global settings page should look like below (NOTE: Please fill in your name on name and email):
mergetool:
winmerge
path to mergetool:
c:/Program Files (x86)/winmerge/winmergeu.exe
mergetool command:
wMerge.sh "$MERGED" "$REMOTE"
difftool:
winmerge
path to difftool:
c:/Program Files (x86)/winmerge/winmergeu.exe
difftool command:
"c:/Program Files (x86)/winmerge/winmergeu.exe" "$LOCAL" "$REMOTE"
line endings: checkout as-is, commit as-is
Navigate to the checklist tab to verify that GIT is all "green" and satisfied with your setup.
在 Git Extensions v2.47.3 上,设置非常简单:
设置 ->全局设置->在“Mergetool”的下拉菜单中手动写入:
WinMerge
并观看奇迹。“Difftool”下拉菜单也是如此。
“WinMerge”选项未预先填充在下拉列表中,这太愚蠢了。那好吧。
On Git Extensions v2.47.3, it's really easy to set this up:
Settings -> Global settings -> in the drop-down for 'Mergetool' write manually:
WinMerge
and watch the miracle.Same for 'Difftool' drop-down.
It's just silly that the 'WinMerge' option isn't pre-populated in the dropdown. Oh well.
在 Windows 7 上,这最终对我有用。请注意我的程序文件路径周围的
"'c:/path/here'"
引号。On windows 7, this is what finally worked for me. Note the
"'c:/path/here'"
quotes around my program files path.@sebastiaan 的答案对我不起作用(也许它已经过时了?)
这些是使用 GitExtensions 2.28 对我有用的“全局设置”:
Mergetool:
winmerge
mergetool 的路径:
D:/path/to/WinMerge/WinMergeU.exe
合并工具命令:
"D:/path/to/WinMerge/WinMergeU.exe" -e "$MERGED"
这会导致 WinMerge 使用 git 生成的“冲突文件”。
-e
允许按 ESC 关闭 winmerge。差异工具:
winmerge
difftool 的路径:
D:/path/to/WinMerge/WinMergeU.exe
Difftool 命令:
"D:/path/to/WinMerge/WinMergeU.exe" -e "$LOCAL" "$REMOTE" -dl "Local" -dr "Remote"
-dl
和-dr
设置左窗格和右窗格的描述。@sebastiaan's answer didn't work for me (maybe it is outdated?)
These are "Global settings" that work for me using GitExtensions 2.28:
Mergetool:
winmerge
Path to mergetool:
D:/path/to/WinMerge/WinMergeU.exe
Mergetool command:
"D:/path/to/WinMerge/WinMergeU.exe" -e "$MERGED"
This causes WinMerge to use the "conflict file" generated by git.
-e
allows pressing ESC to close winmerge.Difftool:
winmerge
Path to difftool:
D:/path/to/WinMerge/WinMergeU.exe
Difftool command:
"D:/path/to/WinMerge/WinMergeU.exe" -e "$LOCAL" "$REMOTE" -dl "Local" -dr "Remote"
-dl
and-dr
set the descriptions for the left and right pane.在配置文件中添加或更改以下内容:
此解决方案在两个方面有所不同:
WinMergeU.exe *conflictfile*
,而两侧调用则受到左侧窗口呈现的影响。代码><<<<<<<
、=======
和>>>>> $MERGED 包含的 >>
标记。$PROGRAMFILES 变量由 git bash 维护,并且(与本机 Windows cmd 上的类似变量不同)它导航到“Program Files (x86)”。
Add or change the following in the config file:
This solution is distinct in two ways:
WinMergeU.exe *conflictfile*
, while the two-sided calls suffer from the fact that left hand window presents<<<<<<<
,=======
, and>>>>>>>
markers that $MERGED contains.The $PROGRAMFILES variable is maintained by git bash and (unlike the similar variable on native windows cmd) it navigates to "Program Files (x86)".