Trying to get git and Beyond Compare to place nicely together on WSL. Here is the output from git config --list
:
diff.tool=bc3
difftool.prompt=false
difftool.bc3.path=/mnt/c/Program Files/Beyond Compare 4/BComp.exe
merge.tool=bc3
mergetool.prompt=false
mergetool.bc3.trustexitcode=true
mergetool.bc3.path=/mnt/c/Program Files/Beyond Compare 4/BComp.exe
Here is my ~/.gitconfig
:
[diff]
tool = bc3
[difftool]
prompt = false
[difftool "bc3"]
path = /mnt/c/Program Files/Beyond Compare 4/BComp.exe
[merge]
tool = bc3
[mergetool]
prompt = false
[mergetool "bc3"]
trustExitCode = true
path = /mnt/c/Program Files/Beyond Compare 4/BComp.exe
my git --version is
:
git version 2.25.1
When I try git difftool file_in_git_repo
Beyond Compare opens with the current version in the left pane, but nothing in the right pane (I have confirmed the file exists in the git repo.)
.git/config
has no entries referencing diff or merge
Any suggestions would be most welcome
========================================================================
Similar to VonC's suggestion, I was able to get it working with this in my .gitconfig file (disclaimer - I have not used the mergetool with this new method):
[diff]
tool = bc3
[difftool]
prompt = false
[difftool "bc3"]
cmd = '/mnt/c/Program Files/Beyond Compare 4/BComp.exe' \"$(wslpath -aw $LOCAL)\" \"$(wslpath -aw $REMOTE)\"
[merge]
tool = bc3
[mergetool]
prompt = false
[mergetool "bc3"]
trustExitCode = true
cmd = '/mnt/c/Program Files/Beyond Compare 4/BComp.exe' \"$(wslpath -aw $LOCAL)\" \"$(wslpath -aw $REMOTE)\"
CodePudding user response:
Check if this configuration might work in your case:
I managed to get it working using the built-in wslpath command which comes with new WSL versions!
My git config on WSL linux side:
difftool.bc3.cmd=BComp.exe "$(wslpath -aw $LOCAL)" "$(wslpath -aw $REMOTE)" mergetool.bc3.cmd=BComp.exe "$(wslpath -aw $LOCAL)" "$(wslpath -aw $REMOTE)" "$(wslpath -aw $BASE)" "$(wslpath -aw $MERGED)"
BComp.exe
is in my$PATH
.
I'm using WSL2 on Windows version 2004 (build 19041), and this works both inside the WSL filesystem and also for the mounted Windows filesystem.The new
wslpath -aw
converts the Linux paths like this:$ wslpath -aw /home/ \\wsl$\Debian\home
And Windows paths like this:
$ wslpath -aw /mnt/c/Users/ C:\Users
This makes them both work perfectly with the Windows version of BC when launched from Linux.