gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 02:32:55 26 4
gpt4 key购买 nike

尝试让 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 是:

git version 2.25.1

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

.git/config 没有引用 diff 或 merge 的条目

欢迎大家提出建议

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

与 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.

关于git with Beyond Compare (4) on WSL2 Windows 11 打不开repo版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71093803/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com