差异工具(vscode)无法从cmd启动 [英] diff tool (vscode) doesn't launch from cmd

查看:354
本文介绍了差异工具(vscode)无法从cmd启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Git,我想将分支lisa合并到我的主分支中,如下所示:

$ git merge lisa

因此,我打开了存储库,然后在Windows资源管理器中打开了.git,以找到.config(Git配置文件):

[diff]
    tool = vscode
[difftool]
    prompt = true
[difftool "vscode"]
    cmd = \"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"$LOCAL\" \"$REMOTE\" --diff --wait
    trustExitCode = false

我的问题是,当我编写以下命令时:

git difftool

我看到了cmd本身的差异,而不是启动vscode进行编辑和合并.

这是什么问题?为什么不启动Visual Code?

也尝试过

git difftool --tool=vscode

但同样的问题.

解决方案

在使用VSCode时,我实际上不需要设置任何difftool.

只需进行合并,然后使用VSCode打开Git repo文件夹的根文件夹.
如果您已安装 GitLens ,则会看到所有更改,包括可能的冲突.您将能够直接从VSCode解决上述冲突.


话虽这么说,"如何使用Visual Studio Code作为Git MergeTool的默认编辑器 "

git config --global diff.tool vscode
git config --global difftool.vscode.cmd "code --wait --diff $LOCAL $REMOTE"

(这里假设C:\\Program Files\\Microsoft VS Code在您的%PATH%$PATH上)

Using Git and I want to merge branch lisa into my master branch, like this:

$ git merge lisa

So I opened my repository and then to .git in the Windows Explorer, to reach the .config (Git config file):

[diff]
    tool = vscode
[difftool]
    prompt = true
[difftool "vscode"]
    cmd = \"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"$LOCAL\" \"$REMOTE\" --diff --wait
    trustExitCode = false

My issue is that when I write the following command:

git difftool

I see the differences in cmd itself, instead of having vscode launched for editing and merging.

What's the issue here? Why isn't Visual Code launched?

Also tried

git difftool --tool=vscode

but same issue.

解决方案

I actually don't need to set any difftool when working with VSCode.

Simply do your merge, then open the root folder of your Git repo folder with VSCode.
If you have installed GitLens, you will see all the changes, including possible conflicts. And you will be able to resolve said conflict directly from VSCode.


That being said, the config needed seems simpler in "How to use Visual Studio Code as Default Editor for Git MergeTool"

git config --global diff.tool vscode
git config --global difftool.vscode.cmd "code --wait --diff $LOCAL $REMOTE"

(this assumes here that C:\\Program Files\\Microsoft VS Code is on your %PATH% or $PATH)

这篇关于差异工具(vscode)无法从cmd启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆