Search code examples
gitvisual-studiodiffbeyondcompare

How to use BeyondCompare from command line, but Visual Studio diff within VS?


When working in Visual Studio, when I diff a file from the Git Changes pane it has always shown the diff within Visual Studio using the VS integrated diff tool.

When working from the command line, I had Beyond Compare set to be the default diff tool by following their instructions.

Recently Visual Studio has upgraded to version 16.11.5

Now my workflow is broken. It seems that when I use git difftool from the commandline, nothing happens. If I refollow the instructions above, then diffing from the commandline starts working again. But this breaks Visual Studio, if I then click a file to diff it in Visual Studio this starts BeyondCompare instead of using the Visual Studio integrated difftool. If I put that back in the Visual Studio options to use the integrated difftool, then that again breaks the command line diff.

How can I configure this as required:

  • Diff commands within Visual Studio use the integrated Visual Studio diff tool.
  • Diff commands from the command line use Beyond Compare.

Solution

  • In git bash, run git config --list to view your current command line settings. These are mine that show Beyond Compare for both diff and merge tools.

    diff.tool=bc
    difftool.bc.path=c:/Program Files/Beyond Compare 4/bcomp.exe
    merge.tool=bc
    mergetool.bc.path=c:/Program Files/Beyond Compare 4/bcomp.exe
    

    In VSCode, I can see changes via the internal diff tool and on the source control menu, I can right-click a changed file and opt to see the changes via the CLI configured difftool (Beyond Compare).

    VSCode Source Control

    This is what you want to get back to with Visual Studio (not VSC), correct?

    Try unsetting all of these settings and see how VS reacts. Does it go back to the default internal diff or not?

    git config --global --unset diff.tool
    git config --global --unset merge.tool 
    

    Otherwise, you might just need to reset your settings in Visual Studio.