Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use VS Code as git diff tool

VS code has nice inbuilt feature to diff two files.

Is it possible to use vs code diff as the diff tool for git?

like image 270
Amitabh Avatar asked Mar 03 '23 03:03

Amitabh


1 Answers

Like Maciej says, gitconfig is the way to go. With this I can set it up to be not just a difftool, but also the merge tool for git.

[diff]
    tool = vscode
[merge]
    tool = vscode
[difftool "vscode"]
    cmd = code --wait --diff $LOCAL $REMOTE
[mergetool "vscode"]
    cmd = code --wait $MERGED

I use VSCode Insiders, to get the latest (but still stable) features ahead of time

[diff]
    tool = vscode
[merge]
    tool = vscode
[difftool "vscode"]
    cmd = code-insiders --wait --diff $LOCAL $REMOTE
[mergetool "vscode"]
    cmd = code-insiders --wait $MERGED

Edit: There is now official VSCode Documentation for this.

In your ~/.gitconfig file:

[merge]
  tool = code
[mergetool "code"]
  cmd = code --wait --merge $REMOTE $LOCAL $BASE $MERGED
like image 181
Max Coplan Avatar answered Mar 05 '23 16:03

Max Coplan