doc/user/project/repository/compare_revisions.md
{{< details >}}
{{< /details >}}
Use Compare revisions to view the list of commits and files changed between revisions.
You can compare:
GitLab provides two methods to compare revisions:
Only incoming changes from source (default): Displays differences from the source after the latest common commit on both revisions. This method excludes unrelated changes made to the target after the source was created. Use this to view only the changes introduced by the source revision.
This method uses the git diff <from>...<to> Git command. It compares
from the merge base (the common ancestor commit) to the target, instead of
comparing the actual commits directly.
Include changes to target after source was created: Displays all differences between the two revisions, including changes made to both the source and target. Use this to view the complete difference between two points in your repository's history.
This method uses the git diff <from> <to> Git command. It compares the actual commits directly,
displaying all changes between them.
To compare revisions:
In the top bar, select Search or go to and find your project.
In the left sidebar, select Code > Compare revisions.
Select the Source revision:
^ matches the beginning of the name: ^feat matches feat/user-authentication.$ matches the end of the name: widget$ matches feat/search-box-widget.* matches using a wildcard: branch*cache* matches fix/branch-search-cache-expiration.^chore/*migration$ matches chore/user-data-migration.Select the Target repository and revision.
Below Show changes, select either Only incoming changes from source (default) or Include changes to target after source was created.
Select Compare.
Optional. To reverse the Source and Target, select Swap revisions ({{< icon name="substitute" >}}).
The comparison page displays the list of commits and files changed between the revisions.
You can preview files directly in their deployed environment when comparing revisions.
Prerequisites:
To preview a file in its deployed environment:
The file opens in a new tab, displaying how it appears in the deployed environment.