Using Visual Studio as diff/merge tool in Git and SourceTree

This article was posted by Michał Dudak on 2016-02-16 in Tools

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.

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. You can find it in the Visual Studio installation folder, under Common7\IDE subfolder.

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.

Commandline Git config

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:

You can now use these to tell the commandline Git to use these when viewing a diff or merging. It’s as simple as executing two git commands:

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

Now, git difftool and git merge commands will launch Visual Studio.

Doing so is of course perfectly possible even without SourceTree. Just add the difftool and mergetool entries to your .gitconfig file (it should be located in your home folder) and execute the two git config commands shown above.


  1. David Lambl says:

    This was just what I was looking for! Thank you

  2. panodk says:

    Perfect. I was wondering how to set this up explicitly in SourceTree

  3. Jon says:

    thanks for this! I’m clueless with the command line so wasn’t sure of the syntax needed for the command and paramaters (quotes, how do they work?)
    so this came in very handy.

    1. I’m glad I could help.

Leave a Reply

Your email address will not be published. Required fields are marked *