如何将 Winmerge 与 Git 扩展一起使用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2468230/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 08:04:12  来源:igfitidea点击:

How to use Winmerge with Git Extensions?

gitsettingswinmergegit-extensions

提问by sebastiaan

I'm using Git Extensionsand 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.

我正在使用Git 扩展,它预先安装并设置 KDiff 作为解决合并冲突的差异工具。我非常喜欢 Winmerge,并想用 Winmerge 替换 KDiff。

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?

在 Git 扩展设置中,有一些设置可以更改 Mergetool,但我似乎无法弄清楚应该使用什么语法以及为什么。似乎有 4 个变量:$BASE、$LOCAL、$REMOTE、$MERGED。似乎我应该将这些传递给 WinMergeU.exe,但是使用哪些命令行参数?

I've tried to search for this a few times, but there is no answer that actually seems to work.

我已经尝试搜索了几次,但没有实际似乎有效的答案。

采纳答案by foxtrotZulu

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.

概述
以下是关于如何设置 GIT 版本控制以便您可以使用比默认安装更好的工具集的说明。安装程序要求已安装 GIT 扩展,并涉及在 GIT 扩展中配置 Winmerge。

Installation
Walk through all the prompts and install in the default directory for Winmerge.

安装
完成所有提示并安装在 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.

在 GIT 版本控制中配置 Winmerge 在
文本编辑器中打开一个新文档。复制/粘贴以下内容并将文档作为“wMerge.sh”保存到您的“C:\Program Files (x86)\Git\bin\”目录。

echo Launching WinMerge:   "C:/Program Files (x86)/WinMerge/WinMergeU.exe" -e -u -dl "Original" -dr "Modified" "" ""

Goto your "Users->username" directory and locate the .gitconfig file. Open it in your favorite editor copy/paste the following code and Save:

转到您的“用户->用户名”目录并找到 .gitconfig 文件。在您最喜欢的编辑器中打开它,复制/粘贴以下代码并保存:

[user]
    name = enter your name
    email = [email protected]
[core]
    autocrlf = false
[merge]
    tool = winmerge
[mergetool "winmerge"]
    cmd = wMerge.sh \"$MERGED\" \"$REMOTE\"
    path = c:/Program Files (x86)/winmerge/winmergeu.exe
[mergetool]
    keepBackup = false
    trustExitCode = false
[diff]
    guitool = winmerge
[difftool "winmerge"]
    path = c:/Program Files (x86)/winmerge/winmergeu.exe
    cmd = \"c:/Program Files (x86)/winmerge/winmergeu.exe\" \"$LOCAL\" \"$REMOTE\"

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.

运行“GitExtensions”,转到“工具->设置->Git 扩展->Git 配置”。如果您已正确完成安装并将工具引用到其目录中,您的全局设置页面应如下所示(注意:请在姓名和电子邮件中填写您的姓名):

mergetool:mergetool 的winmerge
路径:c:/Program Files (x86)/winmerge/winmergeu.exe
mergetool 命令:wMerge.sh "$MERGED" "$REMOTE"
difftool:winmerge
path到 difftool:c:/Program Files (x86)/winmerge/winmergeu.exe
difftool 命令:"c:/Program Files (x86)/winmerge/winmergeu.exe" "$LOCAL" "$REMOTE"

行结束:按原样结帐,按原样提交

导航到清单选项卡以验证 GIT 是否全部“绿色”并且对您的设置感到满意。

回答by Cristian Diaconescu

On Git Extensions v2.47.3, it's really easy to set this up:

在 Git Extensions v2.47.3 上,设置它真的很容易:

Settings -> Global settings -> in the drop-down for 'Mergetool' write manually: WinMergeand watch the miracle.

设置 -> 全局设置 -> 在“合并工具”的下拉菜单中手动编写:WinMerge并观看奇迹。

Same for 'Difftool' drop-down.

'Difftool' 下拉菜单也是如此。

enter image description here

在此处输入图片说明

||   ||   ||
\/   \/   \/

enter image description here

在此处输入图片说明

It's just silly that the 'WinMerge' option isn't pre-populated in the dropdown. Oh well.

'WinMerge' 选项没有预先填充在下拉列表中,这很愚蠢。那好吧。

回答by TimDog

On windows 7, this is what finally worked for me. Note the "'c:/path/here'"quotes around my program files path.

在 Windows 7 上,这最终对我有用。请注意"'c:/path/here'"我的程序文件路径周围的引号。

[merge]
    tool = winmerge
[mergetool "winmerge"]
    cmd = "'C:/Program Files (x86)/WinMerge/WinMergeU.exe'" -e "$MERGED"
[diff]
    tool = winmerge
[difftool "winmerge"]
    cmd = "'C:/Program Files (x86)/WinMerge/WinMergeU.exe'" -e "$LOCAL" "$REMOTE" -dl "Local" -dr

回答by foraidt

@sebastiaan's answer didn't work for me (maybe it is outdated?)

@sebastiaan 的回答对我不起作用(也许它已经过时了?)

These are "Global settings" that work for me using GitExtensions 2.28:

这些是使用 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.
-eallows pressing ESC to close winmerge.

Mergetool:合并工具的winmerge
路径:D:/path/to/WinMerge/WinMergeU.exe
Mergetool 命令:"D:/path/to/WinMerge/WinMergeU.exe" -e "$MERGED"
这会导致 WinMerge 使用 git 生成的“冲突文件”。
-e允许按 ESC 关闭 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"
-dland -drset the descriptions for the left and right pane.

Difftool:difftool 的winmerge
路径:D:/path/to/WinMerge/WinMergeU.exe
Difftool 命令:"D:/path/to/WinMerge/WinMergeU.exe" -e "$LOCAL" "$REMOTE" -dl "Local" -dr "Remote"
-dl-dr设置左右窗格的描述。

回答by Pawel Piskorski

Add or change the following in the config file:

在配置文件中添加或更改以下内容:

[merge]
    tool = winmerge
[mergetool "winmerge"]
    cmd = $PROGRAMFILES/WinMerge/WinMergeU.exe "$PWD/$MERGED"

This solution is distinct in two ways:

此解决方案在两个方面有所不同:

  1. Simply calls WinMergeU.exe *conflictfile*, while the two-sided calls suffer from the fact that left hand window presents <<<<<<<, =======, and >>>>>>>markers that $MERGED contains.
  2. Apply mergetool on per-repo basis - I am editing the $GIT_DIR/config file . Same result could be achieved by calling git config without --system or --global argument. This is to note that there are a few scopes of configuration to choose from.
  1. 简单地调用WinMergeU.exe *conflictfile*,而双面拨打的左手窗口礼物的事受苦<<<<<<<=======>>>>>>>标记,$已合并含有。
  2. 在每个存储库的基础上应用合并工具 - 我正在编辑 $GIT_DIR/config 文件。通过调用没有 --system 或 --global 参数的 git config 可以实现相同的结果。需要注意的是,有几个配置范围可供选择

The $PROGRAMFILES variable is maintained by git bash and (unlike the similar variable on native windows cmd) it navigates to "Program Files (x86)".

$PROGRAMFILES 变量由 git bash 维护,并且(与本机 Windows cmd 上的类似变量不同)它导航到“Program Files (x86)”。