{"meta":{"title":"Comparing commits","intro":"You can compare the state of your repository across branches, tags, commits, forks, and dates.","product":"Pull requests","breadcrumbs":[{"href":"/en/pull-requests","title":"Pull requests"},{"href":"/en/pull-requests/committing-changes-to-your-project","title":"Commit changes to your project"},{"href":"/en/pull-requests/committing-changes-to-your-project/viewing-and-comparing-commits","title":"View & compare commits"},{"href":"/en/pull-requests/committing-changes-to-your-project/viewing-and-comparing-commits/comparing-commits","title":"Comparing commits"}],"documentType":"article"},"body":"# Comparing commits\n\nYou can compare the state of your repository across branches, tags, commits, forks, and dates.\n\nTo compare different versions of your repository, append `/compare` to your repository's path.\n\nWe'll demonstrate the power of Compare by looking at the compare page for [a fork of the Linguist repo](https://github.com/octocat/linguist), which is at <https://github.com/octocat/linguist/compare/master...octocat:master>.\n\nEvery repository's Compare view contains two drop down menus: `base` and `compare`.\n\n`base` should be considered the starting point of your comparison, and `compare` is the endpoint. During a comparison, you can always change your `base` and `compare` points by clicking on **Edit**.\n\n## Comparing branches\n\nThe most common use of Compare is to compare branches, such as when you're starting a new pull request. You'll always be taken to the branch comparison view when starting [a new pull request](/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).\n\nTo compare branches, you can select a branch name from the `compare` drop down menu at the top of the page.\n\nHere's an example of a [comparison between two branches](https://github.com/octocat/linguist/compare/master...octocat:an-example-comparison-for-docs).\n\n## Comparing tags\n\nComparing release tags will show you changes to your repository since the last release.\nFor more information, see [Comparing releases](/en/repositories/releasing-projects-on-github/comparing-releases).\n\nTo compare tags, you can select a tag name from the `compare` drop-down menu at the top of the page.\n\nHere's an example of a [comparison between two tags](https://github.com/octocat/linguist/compare/v2.2.0...octocat:v2.3.3).\n\n> \\[!NOTE]\n> If a branch and a tag have the same name, the branch will be used when comparing commits. You can compare the tag specifically by adding `tags/` to the tag name.\n\n## Comparing commits\n\nYou can also compare two arbitrary commits in your repository or its forks on GitHub in a two-dot diff comparison.\n\nTo quickly compare two commits or Git Object IDs (OIDs) directly with each other in a two-dot diff comparison on GitHub, edit the URL of your repository's \"Comparing changes\" page.\n\nFor example, this URL uses the shortened SHA codes to compare commits `f75c570` and `3391dcc`: `https://github.com/github-linguist/linguist/compare/f75c570..3391dcc`.\n\nTo learn more about other comparison options, see [About comparing branches in pull requests](/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-comparing-branches-in-pull-requests#three-dot-and-two-dot-git-diff-comparisons).\n\n## Comparing across forks\n\nYou can compare your base repository and any forked repository. This is the view that's presented when a user performs a Pull Request to a project.\n\nTo compare branches on different repositories, preface the branch names with user names. For example, by specifying `octocat:main` for `base` and `octo-org:main` for `compare`, you can compare the `main` branch of the repositories respectively owned by `octocat` and `octo-org`.\n\nYou can also preface the branch name with a user name and a repository name. For example, specifying `octocat:awesome-app:main` would use the `main` branch in the `octocat/awesome-app` repository. This can be useful in large organizations, where you might have an upstream repository and a fork both owned by the organization. For more information, see [About forks](/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks).\n\nHere's an example of a [comparison between two repositories](https://github.com/github-linguist/linguist/compare/master...octocat:master).\n\n## Comparisons across commits\n\nYou can compare a single commit in Git to the commit's predecessors using two types of notation.\n\n| Notation | Meaning                                                                                             | Example                                                                        | Comparison                                                                                                      |\n| :------: | :-------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------- |\n|    `^`   | One commit prior. Repeat the `^` character to indicate one more commit further back in the history. | `96d29b7^^^^^`<br/><br/>Represents the commit five commits prior to `96d29b7`. | [View comparison](https://github.com/octocat/linguist/compare/octocat:96d29b7%5E%5E%5E%5E%5E...octocat:96d29b7) |\n|   `~N`   | N commit(s) prior.                                                                                  | `96d29b7~5`<br/><br/>Represents the commit five commits prior to `96d29b7`.    | [View comparison](https://github.com/octocat/linguist/compare/octocat:96d29b7%7E5...octocat:96d29b7)            |\n\n## Further reading\n\n* [Changing the base branch of a pull request](/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request)"}