From WSL2 (Ubuntu) how could one use Meld installed natively on Windows as the git merge and diff tool?
So that commands like git mergetool
& git difftool
from WSL open Meld on Windows.
Make meld
easily accessible in WSL by linking it:
sudo ln -s /mnt/c/Program\ Files\ \(x86\)/Meld/Meld.exe /usr/local/bin/meld
In WSL edit ~/.gitconfig
and add:
[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). Changes will still be copied back to the source files once Meld is closed. Since I use git dir diff tool a lot I've added these aliases in the above file:
[alias]
dt = !git difftool --dir-diff --no-symlinks -t meld
mt = !git mergetool -t meld