Skip to main content
Frecuentemente publicamos actualizaciones de nuestra documentación. Es posible que la traducción de esta página esté en curso. Para conocer la información más actual, visita la documentación en inglés. Si existe un problema con las traducciones en esta página, por favor infórmanos.
GitHub AE está actualmente en un lanzamiento limitado. Por favor, contacta a nuestro equipo de ventas para conocer más sobre esto.

About comparing branches in pull requests

Pull requests display diffs to compare the changes you made in your topic branch against the base branch that you want to merge your changes into.

Note: When creating your pull request, you can change the base branch that you're comparing your changes against. For more information, see "Creating a pull request."

You can view proposed changes in a pull request in the Files changed tab. Pull Request Files changed tab

Rather than viewing the commits themselves, you can view the proposed changes as they'll appear in the files once the pull request is merged. The files appear in alphabetical order within the Files changed tab. Additions to the files appear in green and are prefaced by a + sign while content that has been removed appears in red and is prefaced by a - sign.

Diff view options

Tip: If you're having a hard time understanding the context of a change, you can click View in the Files changed tab to view the whole file with the proposed changes.

You have several options for viewing a diff:

  • The unified view shows updated and existing content together in a linear view.
  • The split view shows old content on one side and new content on the other side.
  • The rich diff view shows a preview of how the changes will look once the pull request is merged.
  • The source view shows the changes in source without the formatting of the rich diff view.

You can also choose to ignore whitespace changes to get a more accurate view of the substantial changes in a pull request.

Diff viewing options menu

To simplify reviewing changes in a large pull request, you can filter the diff to only show selected file types, show files you are a CODEOWNER of, hide files you have already viewed, or hide deleted files. For more information, see "Filtering files in a pull request by file type."

File filter drop-down menu

Three-dot and two-dot Git diff comparisons

By default, pull requests on GitHub show a three-dot diff, or a comparison between the most recent version of the topic branch and the commit where the topic branch was last synced with the base branch.

To see two committish references in a two-dot diff comparison on GitHub, you can edit the URL of your repository's "Comparing changes" page. For more information, see the Git Glossary for "committish" from the Pro Git book site.

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

A two-dot diff compares two Git committish references, such as SHAs or OIDs (Object IDs), directly with each other. On GitHub, the Git committish references in a two-dot diff comparison must be pushed to the same repository or its forks.

If you want to simulate a two-dot diff in a pull request and see a comparison between the most recent versions of each branch, you can merge the base branch into your topic branch, which updates the last common ancestor between your branches.

For more information about Git commands to compare changes, see "Git diff options" from the Pro Git book site.

Reasons diffs will not display

Further reading