Use Visual Studio as your Diff and Merging Tool for local files

Probably you are familiar with the Diff tool that Visual Studio provides when doing Source Control. When comparing two files from Source Control Explorer or the Solution Explorer you get this nice tool that shows a nice visual compare of two files.

You can choose 2 local files, a source control file and a local file, 2 source controlled files etc. Very flexible!

When you check in code, and have a conflict, the merge tool from Visual Studio is presented.


All fine. Problem is that you need Source Control… You cannot choose compare on a file that is not under source control. So what to do when I want to use this tool for 2 local files ??

VsDiffMerge.exe to the rescue

In the tools directory of Visual Studio (C:\Program Files (X86)\Microsoft Visual Studio 11.0 (or 12.0)\Common\IDE\ you find the tool VsDiffMerge.exe

Tip: You can also use %VS110COMNTOOLS% on the commandline to point to this directory.

When you start VSDiffMerge, the diff / merge tool starts up with two files that you choose.


To start the tool to compare two files use the following command

"%VS110COMNTOOLS%/../IDE/vsdiffmerge.exe" "File1" "File2" [/t]


For Example

"%VS110COMNTOOLS%/../IDE/vsdiffmerge.exe" "Person Source.cs" "Person Target.cs"


starts up the IDE with “Person Source.cs” and “Person Target.cs” opened.


Use the /t switch to open the comparison in a “ProvisionalTab”



You can also use this tool to merge 2 files. In order to do this, you need to provide the name of the file that serves as base file, and you need to specify the name of the result file.

The syntax is like this:

"%VS110COMNTOOLS%/../IDE/vsdiffmerge.exe" "File1" "File2" 
"FileThatServesAsBase" "FileThatServesasTarget" /m  
For Example
"%VS110COMNTOOLS%/../IDE/vsdiffmerge.exe" "Person Source.cs" 
"Person Target.cs" "Person Source.cs" "Person Source.cs" /m  
This opens VS like this

Notice that the “FileThatServesAsTarget” is the version that is considered as “Latest” Version

Summary of switches

vsDiffMerge.exe “source file” “target file” “base file” “result file” /t /m
  • /t (open in a provisional tab, don’t use if you want to open in a normal tab)
  • /m (merge operation)



UPDATE 2015-01-22: When you want to set up Source Tree as your Custom Diff and Merge tool when doing Git, follow this great explanation by Terje Sandstrom on his blog


Hope this helps!


18 Responses to “Use Visual Studio as your Diff and Merging Tool for local files”

  1. This does not seem to work with Visual Studio 2012. I keep getting Invalid command line arguments. It appears that it wants two more arguments, but I do not know what they should be.

    • Hi,

      Strange, can you send the command you are using?


      • The exe I tried to use was this:
        C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\vsDiffMerge.exe

        It appears that I need to pass the arguments like this:
        /t /m %1 %2 %3 %3 %3 %4
        %1 = original
        %2 = modified
        %3 = base
        %4 = merged

      • Note that I am not certain that these arguments are actually correct, but it seemed to give the best result in my tests.

  2. Thanks, I was able to use the VS merge tool with TortoiseSVN !

  3. Thanks, very useful! Just a tiny obvious tip: if you are using VS developer command prompt you don’t have to specify path to vsDiffMerge.

  4. I use TFS API : MergeContent(Conflict, true) but not Works for VS 2012 (VS not response)

    useExternalMergeToolType: System.Boolean
    True to use a registered external merge tool; otherwise, false

    I try with DTE Command: File.TfsContextExplorerMerge

    public static void DoMerge(DTE2 app)
    if (app.SelectedItems.Count != 1 || app.SelectedItems.Item(1).ProjectItem.FileCount != 1) return;
    var projectItem = app.SelectedItems.Item(1).ProjectItem;
    var proyectoSW = projectItem.ContainingProject;

    I want show merge tool for view diferentes of files and REsolve Conflicts (and Accept Merge):
    Merge Changes in Merge Tool.

    When you choose this action, the Merge window appears.

    I want do it programmatically.

    Any suggestions?

    • Maybe you can invoke the command line tf merge tool and use noprompt?

      • What’s differences vsDiffMerge.exe and tf.exe merge tools?

        I use vsDiffMerge.exe and now shows tools in tab VS 2012.

        Using /t parameter or not is the same for me.

        var Arguments = string.Format(“\”{0}\” \”{1}\” \”{2}\” \”{3}\” /t /m”, local, localBranch, local, local);
        var info = new ProcessStartInfo
        Arguments = Arguments,
        CreateNoWindow = true,
        FileName = vsdiffmerge,
        UseShellExecute = false,

        How can I get “exit codes” for vsDiffMerge.exe for get results (if user accept merge or not, etc ) ?

  5. Tip: For quick diffing between two local files, you can use the following command from the Visual Studio Command Prompt (verified in VS13)
    Tools.DiffFiles “PathToFile1” “PathToFile2”
    The sweet thing is, you get auto-complete for specifying the file paths!

  6. I found that this also works in Visual Studio 2013. Just change %VS110COMNTOOLS% to %VS120COMNTOOLS%

  7. This only works for me if the target is not the same as the base :-S


  1. How to: Compare two files in Visual Studio 2012 | SevenNet - December 19, 2014

    […] Source: […]

  2. [] Diff Tool for local files | PipisCrew Official Homepage - October 30, 2015

    […] source […]

  3. Use Visual Studio to merge code for an AX 2012 CU - Microsoft Dynamics AX Community - May 9, 2016

    […] very fast. Here is a great explanation about how you use Visual Studios merge tool to merge files: can find of plenty other tools for compare and merge on the Internet, but you probably already […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: