How to: Show Differences between Two Files or File Versions

Team Foundation includes a tool named Difference Viewer that lets you compare two files and identify their differences. The following procedures demonstrate how to compare files, folders, and shelved items. If you need to resolve the differences between two files, see How to: Resolve Conflicts.

Required Permissions

To perform these procedures, you must have the Read permission set to Allow. For more information, see Team Foundation Server Permissions.

Comparing Files

With the Difference Viewer, you can compare two versions of a file. The following procedures demonstrate how to compare two files both from Solution Explorer and Source Control Explorer.

To compare files from Solution Explorer

  1. In Solution Explorer, highlight the file or folder that you want to compare, right-click, and choose Compare.

    The Compare dialog box appears and the Selected file text box shows the file that you chose.

  2. In the Compare to text box, either type the path and name for the file that you want to compare your selected file to, or click the ellipses () to open the Open dialog box from which you can locate the file that you want to compare to.

  3. In the Compare by list box, choose the version that you want to compare by:

    • Changeset

    • Date

    • Label

    • Latest Version

    • Workspace

  4. Click Compare, if the files have no differences, the Microsoft Visual Studio dialog box appears informing you that the files are identical, click OK. Otherwise, the Difference Viewer appears.

  5. In the Difference Viewer, the differences will be highlighted. You can use the toolbar to navigate between all the areas in the file where differences are detected.

  6. When you are finished comparing the files, exit the Difference Viewer.

To compare files from Source Control Explorer

  1. In Source Control Explorer, highlight the file or folder that you want to compare, right-click, and choose Compare.

    The Compare dialog box appears and the Selected file box shows the file that you chose.

  2. In the Compare to text box, either type the path and name for the file that you want to compare your selected file to, or click the ellipse () to open the Open dialog box from which you can locate the file that you want to compare to.

  3. In the Compare by list box, choose the version that you want to compare by:

    • Changeset

    • Date

    • Label

    • Latest Version

    • Workspace

  4. Click Compare, if the files have no differences, the Microsoft Visual Studio dialog box appears informing you that the files are identical, click OK. Otherwise, the Difference Viewer appears.

  5. In the Difference Viewer, the differences will be highlighted. You can use the toolbar to navigate between all the areas in the file where differences are detected.

  6. When you are finished comparing the files, exit the Difference Viewer.

Comparing Shelved Items

You can also use the unshelve command to locate a shelveset on the Team Foundation server and compare each source file revision to the server version upon which it is based. This feature is very useful for peer code reviews. For more information, see Working with Source Control Shelvesets.

To compare a shelved file to its base shelveset version

  1. In Visual Studio 2005 Team System, click File, point to Source Control, and then click Unshelve.

  2. In the Owner name box, type the shelveset creator's name. For example, ADVENTUREWORKS\JuanGo or just, juango.

  3. Click Find.

  4. In the Results pane, select the desired shelveset, and then click Details.

    Warning

    Do not click Unshelve.

  5. In the Details dialog box, right-click a code file, point to Compare, and then click With Workspace Version.

As soon as you locate the shelveset, you can compare each source file revision to the version upon which it is based, by using the Team Foundation Difference Viewer.

See Also

Reference

Difference Command

Concepts

Working with Source Control Changesets
Working with Source Control Workspaces
Working with Labels

Other Resources

Comparing Files in Source Control
Resolving Conflicts (Team Foundation Source Control)