使用 VS Code 作为 git diff 工具

Ami*_*abh 3 git diff visual-studio-code vscode-settings

VS 代码具有很好的内置功能来区分两个文件。

是否可以使用 vs code diff作为git的diff工具?

Max*_*lan 5

就像Maciej说的那样,gitconfig是要走的路。有了这个,我可以将它设置为不仅仅是一个 difftool,而且还是 git 的合并工具。

[diff]
    tool = vscode
[merge]
    tool = vscode
[difftool "vscode"]
    cmd = code --wait --diff $LOCAL $REMOTE
[mergetool "vscode"]
    cmd = code --wait $MERGED
Run Code Online (Sandbox Code Playgroud)

我使用 VSCode Insiders,提前获得最新(但仍然稳定)的功能

[diff]
    tool = vscode
[merge]
    tool = vscode
[difftool "vscode"]
    cmd = code-insiders --wait --diff $LOCAL $REMOTE
[mergetool "vscode"]
    cmd = code-insiders --wait $MERGED
Run Code Online (Sandbox Code Playgroud)


小智 4

是的,\xe2\x80\x99s 是可能的。\n您只需将 Visual Studio Code 设置为默认 difftool,方法是将其添加到~/.gitconfig文件中:

\n
[diff]\n    tool = vscode\n[difftool "vscode"]\n    cmd = code --wait --diff $LOCAL $REMOTE\n
Run Code Online (Sandbox Code Playgroud)\n

完成此操作后,只需运行命令即可,例如:git difftool master。几秒钟后,Visual Studio Code 运行difftool

\n