Compare Revisions

You can compare any two revisions of a Git repository. The base revision indicates the starting point of the comparison and the compare revision indicates the end point. The revision could be a branch, a tag, or a commit SHA-1 checksum hash.

Here's how to compare two revisions of a Git repository:

  1. On the right side of the Git page, click Compare.
  2. From the Base Revision Base Revision drop-down list on the left, select the base revision.
    By default, the Git page selects the last commit of the repository as the base revision and the selected revision as the compare revision.
  3. From the Compare Revision Compare Revision drop-down list on the right, select the compare revision.

You can compare these revisions:

  • Branch versus branch

  • Tag versus tag

  • Commit versus commit

  • Branch versus tag

  • Commit versus branch

  • Tag versus commit

On the Compare Result page, the Changed Files tab and the Commits tab. The Changed Files tab lists files that have changed between the base revision and the compare revision. The Commits tab lists all commits that have happened between the base revision and the compare revision since their common commit. The Commits tab is enabled if From Merge Base is selected in From Merge Base or Revisions From Merge Base or Revisions.

Action How To

Compare with a parent of the base revision

From the Base Revision drop-down list, click the Parents tab, and then click the SHA-1 checksum hash of the parent commit.

View differences between the base revision and the compare revision since the last common commit to both revisions

From the From Merge Base or RevisionsFrom Merge Base or Revisions drop-down list, select From Merge Base (...) . Select Revisions (..) to show the differences between the heads (or tips) of the base revision and the compare revision.

Switch the base revision and the compare revision

Click Switch Base Switch Base.

Create or open a merge request

If a merge request exists with the Compare Revision as the review branch, click the merge request button to open the merge request review page.

If a merge request doesn’t exist, click + Merge Request to create a merge request with Base Revision as the target branch and the Compare Revision as the review branch.

View the compare options

Click Diff Preferences Diff Preferences to view various compare options.

Add Comments to a File

When you're comparing files, you can add inline comments, which will be visible to all project users, to the source code changes made to a file:

  1. Browse to and open the file.
  2. On the right side of the page, click Logs.
  3. For the commit that changed the file and added the changes you want to comment on, click the button with the first seven characters of the commit’s SHA-1 checksum hash as the label.
  4. In the Changed Files tab of the Compare view, mouse-over the line number of the file and click Add Comment Add Comment
    If you selected the Unified view, click the line number in the second column. If you selected the Side by Side view, click the line number of the file on the right.
  5. In the Leave a comment box, enter the comment, and click Comment.
The comment is added as an inline comment to the file and is visible to all project members. To reply to a comment, click Reply reply, enter the comment in the Leave a reply box, and click Comment.