Web Code Blog

A web repository of coding tips and knowledge base articles

Archive for January, 2011

Using KDiff for your TFS comparison and merging tool

Posted by Stefan Zvonar on January 4, 2011

TFS is a great source control solution, however it can be a pain when trying to merge or even compare code when merging branches together (especially when you cut and paste code into a new IF statement – the code comparison gets shuffled down considerably, making comparing the two changesets very difficult).

Thankfully, KDiff is a free tool which performs much better than the default tools (in my opinion).

You can download and install KDiff from here:

http://kdiff3.sourceforge.net/

Once you have installed Kdiff, it is now time to configure TFS.

Go to Tools -> Options:

Options

Go to Source Control -> Visual Studio Team Foundation Server -> Configure User Tools:

Configure User Tools

You will now want to add two new operations for comparing and merging.

Note, in the following picture examples, replace ‘C:\Program Files\KDiff3’ with the path where you have installed KDiff.


Compare operations

Compare Operator

Note, the arguments are:

%1 –fname %6 %2 –fname %7

Merge operations

Merge Operator

Note, the arguments are:

%3 –fname %8 %2 –fname %7 %1 –fname %6 -o %4

That should be it.  This will now ensure that TFS will use the KDiff tool when comparing any type of file.  Note, you can change these operations to be specific to certain code files (instead of an ‘.*’ extension, you could use ‘.vb’,  for example)

If you would like more information on the arguments used or use a different comparison tool, please read the following informative post:

http://blogs.msdn.com/b/jmanning/archive/2006/02/20/diff-merge-configuration-in-team-foundation-common-command-and-argument-values.aspx

Hope this helps,

Stefan.

For more Web Code, ASP.NET, SQL Server and other development tips, please check back here at webcodeblog.com often.

Posted in Team Foundation Server, Visual Studio | 2 Comments »

 
Follow

Get every new post delivered to your Inbox.