TFS Merge Pain and Suffering

If you're part of a team that's using Team Foundation Server for source control, you've probably felt the pain related to merge conflicts. I'm sure you've seen this window before:

Image Source

I'm sure this image brings back great memories!

However, when you click the button "Merge Changes in Merge Tool", the DiffMerge utility that ships with the TFS client is loaded-up to resolve the conflict. However, my experience has been that it falls down in real-life scenarios. Typically, it does not clearly show what is being changed between two versions of the same file. Basically, it'll point-out which lines of code are conflicting leaving you with the responsibility of figuring-out how they differ. Not good!

Here's a screen shot of the default TFS merge utility:

Image Source

Another shortcoming of the default TFS merge utility is that it performs a two-way merge. A two-way merge only compares two files - the one already checked into TFS and yours. However, a three-way merge includes the same two files that a two-way merge contains, however, it adds a third file which is the common ancestor of both versions. Basically, it's the version of the file in TFS before both parties changed it. Three-way merges do a much better job of demonstrating changes related to merge conflicts.

My suggestion is to configure Visual Studio to use a better utility when merging files like this. My personal favorite is SourceGear DiffMerge. Here's a screen shot of it:

Here's an explanation of this window coming straight from the DiffMerge documentation with a few tweaks:

This is a three-way merge window that shows the differences between three files; typically this is a common ancestor (in the middle) and two branches that have independently evolved (on the left and right). You can use this window to see the changes side-by-side-by-side. You can edit the center file and merge in changes from both branches, creating a common/unified version.

Link to Documentation

You can find the documentation explaining how to configure Visual Studio to use SourceGear DiffMerge here.

If you find this documentation on how to configure Visual Studio unclear, send me a note and I'll look into putting together a post explaining it a little better.