我是第一次上Git的在线课程。在课程中,讲师使用P4merge作为difftool和mergetool。然而,我正在使用Visual Studio Code。使用Visual Studio Code作为一个困难工具工作得很好,但它不能作为一个合并工具。我一直在网上寻找答案,但没有运气。
这是我调用mergetool时在终端上的截图。
不是打开Visual Studio Code,它给了我一个错误。
MacOS用户:
code
不在你的PATH中,所以当git试图用命令code
执行VSCode时,它找不到它。
要解决这个问题,打开VSCode,打开命令面板(⇧+⌘+ p),并键入:Shell Command: Install 'code' command in PATH
然后按enter并赋予其安装权限。
这将安装code
到您的PATH,并将解决您的问题。
我假设您在gitconfig中添加了以下配置
[merge]
tool = vscode
[mergetool "vscode"]
cmd = code --wait $MERGED
[diff]
tool = vscode
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
你得到关于command not found
的错误是因为你没有导出vscode二进制文件到你的$PATH。试着这样做(我用的是Mac)
export PATH=$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin/
和你应该能够使用git mergetool
打开Vscode。