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]
"%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
"%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!