Git difftool / mergetool with Visual Studio Code

Many developers already use Visual Studio Code, which is a free open-source program available for Linux, macOS and Windows. VS Code can do Git 3-way merge.

VS Code for Git difftool and mergetool:

git config --global diff.tool vscode

git config --global merge.tool vscode

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

git config --global mergetool.vscode.cmd "code --wait --merge \$REMOTE \$LOCAL \$BASE \$MERGED"

Note the backslashes so that the shell doesn’t gobble the “$” variables before they’re saved to user global ~/.gitconfig.

This process assumes that VS Code shell command is setup.

Alternative: Meld