Visual Studio Git Diff



This article was updated for Visual Studio 2017.

  1. Visual Studio Git Diff Show Whitespace
  2. Vs Code Git Diff
  3. Visual Studio Git Tutorial
  4. Visual Studio Code Git Diff

You can configure Git to use Visual Studio as your merge or diff tool in Global Settings and Repository Settings by selecting Use Visual Studio. To configure other diff and merge tools, use git config with the diff.tool or merge.tool switch. Open an existing Git repository. If your code is already on your machine, you can open it by using.

Today, a short note on how to set up Visual Studio as a diif and merge tool in SourceTree and Git client. It’s not commonly known that this IDE may be used for resolving merge conflicts, but as you’ll see it’s very simple to set up.

Visual Studio Git DiffVisual Studio Git Diff

SourceTree config

First, open up the options window and go to Diff tab.

Change both External Diff Tool and Merge Tool to Custom. In the Diff Command field enter the full path to the vsdiffmerge.exe. For VS 2015 and below you can find it in the Visual Studio installation folder, under Common7IDE subfolder. Visual Studio 2017 has it slightly more hidden. Look under Common7IDECommonExtensionsMicrosoftTeamFoundationTeam Explorer.

As for the arguments fields, type in the following:

Diff tool: '$LOCAL' '$REMOTE' 'Source' 'Target' //t
Merge tool: '$LOCAL' '$REMOTE' '$BASE' '$MERGED' //m

Click OK, and And that’s it! Now whenever a merge conflict occurs, you’ll be able to resolve it using Visual Studio.

The only downside I found is that vsdifftool may take quite some time to start up. But if you don’t close it after diffing each file, it’ll work like a charm.

Visual Studio Git Diff Show Whitespace

Commandline Git config

Vs Code Git Diff

By saving these settings in SourceTree, your .gitconfig file is updated with two entries: [difftool “sourcetree”] and [mergetool “sourcetree”]. In my case it looks like the following: