次の方法で共有


Compare files

You can use the Diff window to see the difference between two files or two versions of the same file. If one of the versions of the file is checked out in your workspace, you can modify the file as you run the comparison. You can also use this window to conduct a code review of some changes to a file.

  • Highlight code changes and make comparisons

    • Compare and edit a file in your workspace with a file on the server

    • View and comment on changes in a code review

    • Compare two versions of a file on your server

    • Compare two files using the Compare dialog box

  • Use the Diff window

  • Use the command prompt

Highlight code changes and make comparisons

Compare and edit a file in your workspace with a file on the server

You can highlight and more easily examine the work you have done by comparing a file in your workspace with the version you checked out. You can also compare your work with the latest version on your Team Foundation Server, and edit the file while you are comparing it.

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

  2. Choose Home iconHome, and then choose Pending Changes iconPending Changes.

  3. On the Pending Changes page, locate the file. 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.

      Tip

      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.

Tip

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.

View and comment on changes in a code review

When you participate in a code review, you use the Diff window to see the code changes that are the subject of the review.

Compare two versions of a file on your server

You can compare two versions of a file in the history of that file on your Team Foundation Server.

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

  2. In Source Control Explorer, open the shortcut menu for the file (select the file and right-click) and then choose View History.

  3. Select two versions of the file, open the shortcut menu, and then choose Compare.

    The Diff window appears.

Compare two files using the Compare dialog box

You can compare any two files. The files can both reside on the local client, 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, open the shortcut menu for the file (select the file and right-click) and then choose 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 from the Type menu: Changeset, Date, Label, Latest Version, or Workspace Version. Use the fields that appear to specify the version.

  4. Choose OK.

Use the Diff window

Comaring 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 differenceNext difference (Keyboard: F8).

    • To the previous difference, choose Previous differencePrevious 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 an ALM Developer: Suspend work, fix a bug, and conduct a code review.

Use the command prompt

See Also

Tasks

Compare folders