简体   繁体   English

如何在 WSL2 上使用 Meld 作为 git mergetool 和 difftool?

[英]How to use Meld as git mergetool & difftool on WSL2?

From WSL2 (Ubuntu) how could one use Meld installed natively on Windows as the git merge and diff tool?从 WSL2 (Ubuntu) 如何使用在 Windows 上本地安装的 Meld 作为 git merge 和 diff 工具? So that commands like git mergetool & git difftool from WSL open Meld on Windows.因此,来自 WSL 的git mergetoolgit difftool命令在 Windows 上打开 Meld。

Make meld easily accessible in WSL by linking it:制作meld在WSL方便通过链接它:

sudo ln -s /mnt/c/Program\ Files\ \(x86\)/Meld/Meld.exe /usr/local/bin/meld

In WSL edit ~/.gitconfig and add:在 WSL 中编辑~/.gitconfig并添加:

[diff]
        tool = meld
[difftool "meld"]
        cmd = meld \"$(wslpath -aw $LOCAL)\" \"$(wslpath -aw $REMOTE)\"
[merge]
        tool = meld
[mergetool "meld"]
        cmd = meld --auto-merge \"$(wslpath -aw $LOCAL)\" \"$(wslpath -aw $BASE)\" \"$(wslpath -aw $REMOTE)\" --output \"$(wslpath -aw $MERGED)\" --label=Local --label=Base --label=Remote --diff \"$(wslpath -aw $BASE)\" \"$(wslpath -aw $LOCAL)\" --diff \"$(wslpath -aw $BASE)\" \"$(wslpath -aw $REMOTE)\"

To make git difftool --dir-diff work you need to use it with --no-symlinks (the symbolic links in \\\\wsl$\\ don't seem to currently work when opening from Windows apps).要使git difftool --dir-diff工作,您需要将它与--no-symlinks一起使用( \\\\wsl$\\的符号链接当前似乎在从 Windows 应用程序打开时不起作用)。 Changes will still be copied back to the source files once Meld is closed.关闭 Meld 后,更改仍将复制回源文件。 Since I use git dir diff tool a lot I've added these aliases in the above file:因为我经常使用 git dir diff 工具,所以我在上面的文件中添加了这些别名:

[alias]
        dt = !git difftool --dir-diff --no-symlinks -t meld
        mt = !git mergetool -t meld

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM