using vscode as git version (2.31.1) difftool

452 Views Asked by At

I installed git version 2.31.1.windows.1 and followed all the necessary steps shown in all git step by step trying to use VSCode as my main difftool, I put these lines in gitconfig files:

[diff]
    tool = vscode
[difftool "vscode"]
    cmd = "code --wait --diff $LOCAL $REMOTE"
[difftool]
    prompt = true

Using the followingsteps:

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

And even added VSCode to the PATH in windows, though I don't have a problem opening the VSCode when running git config --global -e, but when I enter the command git difftool nothing happens, it just starts a new line.

1

There are 1 best solutions below

0
On BEST ANSWER

If there is no diff to display, git difftool doesn't open anything -- much like git diff returns without outputting any line.


There is a known gotcha with git diff/git difftool : without further arguments, it displays the diff between what is staged and your files on disk ; if all of your changes are staged (git added), then nothing is displayed.

If you want to view the changes that are staged compared to your current repo state, run :

git diff --cached
# or :
git difftool --cached

Extra note : a useful option to git difftool is -d :

git difftool -d --cached
git difftool -d <branch1> <branch2>
git difftool -d <anything that can get compared ...>

Rather than opening files one by one, it opens your diff viewer in "directory diff" mode.