Comparing commits

You can compare the state of your repository across branches, tags, commits, forks, and dates.

To compare different versions of your repository, append /compare to your repository's path.

We'll demonstrate the power of Compare by looking at the compare page for a fork of the Linguist repo, which is at

Every repository's Compare view contains two drop down menus: base and compare.

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.

Comparing branches

The 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.

To compare branches, you can select a branch name from the compare drop down menu at the top of the page.

Here's an example of a comparison between two branches.

Comparing tags

Comparing release tags will show you changes to your repository since the last release. For more information, see "Comparing releases."

To compare tags, you can select a tag name from the compare drop-down menu at the top of the page.

Here's an example of a comparison between two tags.

Comparing commits

You can also compare two arbitrary commits in your repository or its forks on GitHub in a two-dot diff comparison.

To 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.

Por ejemplo, esta URL utiliza los códigos de SHA acortados a siete caracteres para comparar las confirmaciones c3a414e y faf7c6f:

To learn more about other comparison options, see "Three-dot and two-dot diff comparisons."

Comparing across forks

You 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.

To 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.

Here's an example of a comparison between two repositories.

Comparisons across commits

As a shortcut, Git uses the ^ notation to mean "one commit prior."

You can use this notation to compare a single commit or branch against its immediate predecessors. For example, 96d29b7^^^^^ indicates five commits prior to 96d29b7, because there are five ^ marks. Typing 96d29b7^^^^^ in the base branch and 96d29b7 in the compare branch compares the five commits made before 96d29b7 with the 96d29b7 commit.

Here's an example of a comparison using the ^ notation.

Further reading

¿Te ayudó este documento?

Política de privacidad

¡Ayúdanos a hacer geniales estos documentos!

Todos los documentos de GitHub son de código abierto. ¿Notas algo que esté mal o que no sea claro? Emite una solicitud de cambios.

Haz una contribución

O, aprende cómo contribuir.