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:
-
On the right side of the Git page, click Compare.
-
From the 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. -
From the 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
.
| 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 Revisions |
|
Switch the base revision and the compare revision |
Click 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 |
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:
-
Browse to and open the file.
-
On the right side of the page, click Logs.
-
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.
-
In the Changed Files tab of the Compare view, mouse-over the line number of the file and click 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. -
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
, enter the comment in the Leave a reply box, and click Comment.