Compare files

Last Update: 12/9/2016

Team Services | TFS 2015 | Visual Studio 2015 | Visual Studio 2013


Using Git for version control? See our tutorial for comparing files with Git and Visual Studio.
Not using version control but need to compare two files? Open the Diff window directly with the devenv.exe tool with the /diff option from the Developer Command Prompt to compare any two files on your computer.

Compare any two files using the Compare dialog

Compare any two files. The files can both reside on the local system, both on your Team Foundation Server, or one on each.

  1. On the menu bar, choose View, Other Windows, Source Control Explorer.

  2. In Source Control Explorer, right-click a file and select Compare.

    The Compare dialog box appears.

  3. Specify the two files you want to compare - one under Source Path and the other under Target Path:

    • Type a path, or open the Browse menu, choose Local Path or Server Path, and then browse to choose the file.

    • Choose an option to specify file the server file version when specifying a Server Path from the Type menu: Changeset, Date, Label, Latest Version, or Workspace Version.


    To compare any two local files, select Local Path... from both Browse... drop downs in the Compare dialog.

  4. Choose OK.

Compare files in your workspace with the most recent version

Compare your work with the latest version on your Team Foundation Server while continuing to make changes.

  1. If you are not already connected to the team project that you want to work in, then connect to the team project.

  2. From Team Explorer, open the Pending Changes view.

  3. On the Pending Changes view, locate the file in the Included Changes list. Open the shortcut menu for this file (select the file and right-click), and then:

    • Choose Compare with Workspace Version to see what changes you have made to the version you checked out.


      You can also press Ctrl+Shift and then double-click the file.

    • Choose Compare with Latest Version to see how the changes you have made compare to the latest version of the file on your Team Foundation Server.

  4. The Diff window appears. You can continue to make changes to the file in this window.


You can also use Solution Explorer and the Source Control Explorer windows to compare the file in your workspace with a version of the file on the server. Select a file, open its shortcut menu (right-click), and then choose Compare. When the Compare dialog box appears, choose OK.

Compare two versions of a file in your TFVC history

Compare two versions of a file already checked into Team Foundation Version Control:

  1. On the menu bar, choose View, Other Windows, Source Control Explorer.

  2. In Source Control Explorer, right-click a file and select View History.

  3. Select two versions of the file, right-click and select Compare.

Use the Diff window

The Diff window in Visual Studio shows the difference between two files. If one of the files is checked out in your workspace, you can modify the file as you run the comparison.

Comparing two versions of a file

Comparison window layouts Step 1 Deleted text

Step 2 Added text

Step 3 Changed text

Step 4 Code review comment

Step 5 Visual summary of the differences between the files

Here are some tips for working with the Diff window:

  • Although Side-by-side mode is generally more effective in most cases, you can use whichever mode works best for you and the code you are examining.

  • To skip:

    • To the next difference, choose Next difference Next difference (Keyboard: F8).

    • To the previous difference, choose Previous difference Previous difference (Keyboard: Shift+F8).

    • Back and forth in the file, choose a section of the Step 5 visual summary.

  • When you participate in a code review, you use the Diff window to see the code changes that are the subject of the review. For more information, see Day in the life of a devops Developer: Suspend work, fix a bug, and conduct a code review.

Merge changes between versions

Copy and paste changes from the diff view into the version in your workspace to make quick updates to bring in updates from one version to another. Merge more complex changes between two versions when you resolve merge conflicts in TFVC before making a check-in.

If you need to merge two files with significant differences outside of TFVC conflict resolution, use the vsdiffmerge command line tool. The vsdiffmerge tool allows you to merge changes side-by-side and pick which contents you want to keep for each difference between the files. Run the command with four file parameters followed by the /m flag from the Visual Studio Developer Command Prompt to bring up the merge tool directly against any tow files.

The basic syntax for vsdiffmerge.exe is:

vsdiffmerge.exe "File1" "File2" "Base file" "Result file" /m

File1 and File2 are the full path to the files you want to merge. The Base file is the full path to the file both files are based off of, and Result file is the full path to where you want to write the merged results.

Use the command prompt

See Also

Compare folders