To compare different versions of your repository, append /compare to your repository's path. The compare page uses base as the starting point and compare as the endpoint.
Comparing branches
Use the Compare view to compare branches or start a pull request.
- Navigate to
https://github.com/OWNER/REPOSITORY/compare. - Use the
basedropdown menu to select the branch you want to compare against. - Use the
comparedropdown menu to select the branch that contains the changes. - Review the commits and changed files in the comparison.
See Branches.
Comparing tags
Compare release tags to review changes between releases. See 比较发行版.
- Navigate to
https://github.com/OWNER/REPOSITORY/compare. - Select the older tag from the
basedropdown menu. - Select the newer tag from the
comparedropdown menu. - Review the commits and changed files in the comparison.
注意
If a branch and a tag have the same name, the branch is used. To compare the tag, add tags/ before the tag name.
Comparing commits
You can compare two commits or Git Object IDs (OIDs) directly by editing the compare URL.
- Navigate to the repository's compare page.
- In the URL, enter the older commit as the base and the newer commit as the compare point.
例如,此 URL 使用缩短的 SHA 代码比较提交 f75c570 和 3391dcc:https://github.com/github-linguist/linguist/compare/f75c570..3391dcc。
See Branches.
Comparing across forks
Use owner-qualified branch names to compare branches across forks.
- Navigate to the base repository's compare page.
- Click compare across forks if the option is shown.
- Select the base repository and branch.
- Select the head fork and compare branch.
You can also edit the URL directly. For example, use octocat:main as base and octo-org:main as compare to compare the main branches of repositories owned by octocat and octo-org. See Forks.
Comparisons across commits
To compare a commit with earlier commits, use Git's ^ or ~N notation in the compare URL. For example, 96d29b7~5...96d29b7 compares 96d29b7 with the commit five commits before it.
Differences between commit views
The repository commit history and a single file's commit history can show different results. A file's history shows commits that affected that file, while the repository history shows the broader branch history. If a file's history does not include the commit you need, use the repository's commits page instead.
See the "History Simplification" section of the git log documentation.