Partilhar via


Review history

TFS 2017 | TFS 2015 | TFS 2013

Visual Studio 2019 | Visual Studio 2017 | Visual Studio 2015

Git uses the parent reference information stored in each commit to manage a full history of your development. Review this commit history to find out when file changes were made and determine differences between versions of your code.

Git's use of feature branches and merges through pull requests mean that the commit history of your development doesn't form a straight, chronological line. When you use history to compare versions, think in terms of file changes between two commits instead of file changes between two points in time. A recent change to a file in the main branch may have come from a commit created two weeks ago in a feature branch but was only merged yesterday.

In this tutorial you learn how to:

  • Compare files
  • Retrieve files
  • Compare branches

Compare files

Compare the changes between two versions of a file in your Git repo.

  1. In your project, click Repos, and then click Files.

    Screenshot that shows the Azure DevOps menu with Repos and Files selected.

  2. Select a file, and then click the Compare tab. A diff view shows the most recent commit and the head commit in a side-by-side view.

    Screenshot that shows the Compare tab selected and commit diff view.

  3. Select the the two commits you want to compare.

    Screenshot that shows the selections for the previous commits for comparison.

Retrieve files

Retrieve a specific version of a file from your history, even if the file was deleted or renamed in the latest version of your code. Retrieving an older version of the file doesn't make any changes to your current branch. Create a new commit to bring the older version of the file into your branch.

  1. In your project, click Repos, and then click Files.

    Screenshot that shows the Azure DevOps menu with the Repo menu expanded and Files selected.

  2. Select a file, and then select the History tab.

    Screenshot that shows a the 'History' tab of a file selected.

  3. Select a commit from the list.

  4. Click the ellipses in the top-right corner, and then select Revert from the drop-down.

    Screenshot that shows the ellipsis and the drop-down with 'Revert' selected.

  5. Select your target branch, type a topic branch name if necessary, and click Revert.

    Screenshot that shows the 'Revert commit' dialog.

Compare branches

Review potential changes from a merge or rebase by comparing branches directly. You can compare both local and remote branches, which is useful when checking for potential merge conflicts or to see how the changes others have made will affect your work.

  1. In your project, click Repos, and then click Branches.

    Screenshot that shows selecting 'Repos' and 'Branches' from the project menu.

  2. On the branch you want to compare, click the ellipses on the right-side, and then select Compare branches from the drop-down.

    Screenshot that shows the ellipsis selected and 'Compare branches' selected from the menu.

  3. Select the other branch you want to compare with. The view displays all changes between the branches.

    Screenshot that shows the 'Branch compare' dialog, with the first branch drop-down highlighted and branch 'Test1' selected.