git with Beyond Compare (4) on WSL2 Windows 11 未打开 repo 版本

git with Beyond Compare (4) on WSL2 Windows 11 not opening the repo version

试图让 git 和 Beyond Compare 在 WSL 上很好地并列。这是 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

这是我的 ~/.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

我的git --version is:

git version 2.25.1

当我尝试时 git difftool file_in_git_repo Beyond Compare 在左窗格中打开当前版本,但右窗格中没有任何内容(我已确认该文件存在于 git 存储库中。)

.git/config 没有引用差异或合并的条目

欢迎提出任何建议

============================================= ===========================

与 VonC 的建议类似,我能够在我的 .gitconfig 文件中使用它(免责声明 - 我没有将 mergetool 与这种新方法一起使用):

[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)\"

检查 this configuration 是否适用于您的情况:

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.