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

发布于 2024-08-25 18:19:46 字数 330 浏览 5 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

最丧也最甜 2024-09-01 18:19:46

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

安装
完成所有提示并安装在 Winmerge 的默认目录中。

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

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

转到“用户->用户名”目录并找到 .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\"

运行“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.

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

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

[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.

放赐 2024-09-01 18:19:46

在 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.

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.

鱼忆七猫命九 2024-09-01 18:19:46

在 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

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

[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
丿*梦醉红颜 2024-09-01 18:19:46

@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.

祁梦 2024-09-01 18:19:46

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

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

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

  1. 只需调用 WinMergeU.exe *conflictfile*,而两侧调用则受到左侧窗口呈现 的影响。代码><<<<<<<=======>>>>> $MERGED 包含的 >> 标记。
  2. 在每个存储库的基础上应用 mergetool - 我正在编辑 $GIT_DIR/config 文件。通过调用不带 --system 或 --global 参数的 git config 可以获得相同的结果。值得注意的是,有一些范围可供选择的配置。

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

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.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文