To always control exactly what is about to be commited is a best practice when working with source control. Unfortunately the TFS tooling is very limited, so I prefer using TortoiseMerge which is part of the TortoiseSVN package.
Diff
Using the built in TFS merge tool (diffmerge.exe) checking pending changes looks like this.
Looking at the diff, I see that I’ve added a SeatCount
property correctly. I also see that there is a using
statement left behind that I introduced when planning to use a collection of seat objects. With the TFS merge tool, I have to go back at this point to the source file, update it and then diff again. If I’m lucky I do get all the white space (tabs, spaces and line breaks) identical to avoid committing an unrelated change at the top of the file. Using TortoiseMerge this is much easier.
TortoiseMerge has better visual feedback on what the changes are and also offers a quick way to undo parts of the pending changes. To change to using TortoiseMerge is just a matter of installing TortoiseSVN and a minor config change. TortoiseMerge also offers a better experience when merging.
Merge
The TFS merge tool looks about the same as the diff tool.
Once again, TortoiseMerge offers both better visual feedback and better control over the merge process. Note the colour coded overview of the file to a left. When handling files with a large number of lines it indicates what part of the file is currently displayed. It gives a really good overview of where the conflicts are in the file and where there are merely changes that were merged automatically.
Config
The configuration for this is done in Visual Studio under Tools->Options, Expand Source Control->Visual Studio Team Foundation Server and press “Configure User Tools”. Then press “Add” to add first the merge tool and then the diff tool.
The command should be set to the full path of the TortoiseMerge executable, e.g. C:\Program Files\TortoiseSVN\bin\TortoiseMerge.exe
.
The arguments for the Compare operation are
/base:%1 /mine:%2 /basename:%6 /minename:%7
The arguments for the Merge operation are
/base:%3 /mine:%2 /theirs:%1 /basename:%8 /minename:%7 /theirsname:%6 /merged:%4 /mergedname:%9
Thanks Peter Provost for the config instructions, including the explanation of the mysterious arugments.
Get Visual Studio 2012
When I wrote this post I had only tested Visual Studio 2012 very briefly. The VS2012 diff and merge tools are indeed improved, but still lacks the important feature to undo single lines in the diff tool. In a real project, the VS2012 tools lasted only a few days before I switched to TortoiseMerge.
I started writing this post several months ago, but only finished it and published it now. With the VS2012 release it’s actually quite obsolete because the new diff and merge tools in VS2012 are great themselves. If you prefer TortoiseMerge it’s still possible to use exactly the same configuration in VS2012, but first give VS2012 a try.
I like to use the DiffMerge tool (from SourceGear vault) for the same. The diff tool even highlights difference details upto character level between same lines on the two compare files.
http://www.sourcegear.com/diffmerge/
http://writeln.wordpress.com/2012/07/04/diffmerge-visual-studio-and-ignore-white-space/
Hi!
I found your post quite interesting. I have tried the Diff tool from VS2013, what it appears to me that it still lacks the ability to discard single lines. Is there a way to do it?
Thanks!
There’s no possibility as far as I know to discard single lines with the built in tools. That’s why I prefer using an external diff tool such as TortoiseSvn.
Thanks!
This post made my day :)
This also works for VS 2015/2017… but only for text files. What about MS Office documents? I’m especially interested in Excel.