Meld is a great tool originally developed for linux. It is used as git diff and merge tool. In this article I ll tell you how to setup meld as git tool in wsl in some easy steps.
Step 1
Install meld on windows 10
Step 2
Create meld link as linux app in wsl
$ sudo ln -s /mnt/c/Users/pro/AppData/Local/Programs/Meld/Meld.exe /usr/local/bin/meld
Step 3
Open wsl terminal and edit your gitconfig
$ vi ~/.gitconfig
Add following lines to your .gitconfig file
[ 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)\"

Step 4
use meld as difftool in git like below
$ git difftool --dir-diff master
You would see it working like below

But why it is showing warning icons with files and even showing error when you try to open a file

This is happening due to meld is not able to find exact file paths in wsl.
Step 5
To resolve file link issue in meld for wsl we need to use –no-symlinks with git difftool command
$ git difftool --dir-diff --no-symlinks master

Now we are all good to see file diffs. Double click on any file to see its diff with original file.

Now you can compare both branches and move the code here and there.
Bonus:
You can create an alias for difftool command along with no-symlink and place it in your .bashrc file
alias ddt='git difftool --dir-diff --no-symlinks'
and use it as
$ ddt master
Recent Comments