Skip to main content

Committing and reviewing changes to your project in GitHub Desktop

GitHub Desktop tracks all changes to all files as you edit them. You can decide how to group the changes to create meaningful commits.

About commits

De forma similar al guardar un archivo que se editó, una confirmación registra los cambios en uno o más archivos en tu rama. Git asigna una ID única a cada comentario, a la cual se le llama SHA o hash, la cual identifica:

  • Los cambios específicos
  • Cuando se realizaron los cambios
  • Quién creó los cambios

Cuando realizas una confirmación, debes incluir un mensaje de confirmación que describa brevemente los cambios. You can also add a co-author on any commits you collaborate on.

Si las confirmaciones que haces en GitHub Desktop se asocian con la cuenta incorrecta de GitHub, actualiza la dirección de correo electrónico en tu configuración de Git utilizando GitHub Desktop. For more information, see "Configuring Git for GitHub Desktop."

Repository administrators can enable rulesets for a branch to enforce specific conventions when committing. For example, a ruleset can require a commit to be signed, or for an issue number to be referenced at the start of a commit message. GitHub Desktop will display a warning and prevent committing if a commit does not follow the rulesets. For more information, see "Acerca de los conjuntos de reglas."

Choosing a branch and making changes

  1. Create a new branch, or select an existing branch by clicking Current Branch on the toolbar and selecting the branch from the list.

    Screenshot of the "Current Branch" dropdown view. Under "Recent Branches", a branch, named "my-feature", is highlighted with an orange outline.

  2. Con el editor de texto que prefieras, como Visual Studio Code, haz los cambios necesarios en los archivos del proyecto.

Choosing how to display diffs

You can change the way diffs are displayed in GitHub Desktop to suit your reviewing needs.

To change how you view diffs, in the top-right corner of the diff view, click .

  • To change how the entire diff is displayed, under "Diff display", select Unified or Split. The Unified view shows changes linearly, while the Split view shows old content on the left side and new content on the right side.
  • To hide whitespace changes so you can focus on more substantive changes, select Hide Whitespace Changes.

Screenshot of the diff view of a "README" file. A gear icon is outlined in orange above an expanded dropdown displaying "Whitespace" and "Diff display" settings.

If you need to see more of the file than GitHub Desktop shows by default, you can expand the diff.

  • To see the next few lines above or below the highlighted changes, click the arrow above or below the line numbers.
  • To see the entire file, right-click in the diff view and click Expand Whole File.

Screenshot of the diff view of a "README" file. Over a green "addition" line, in a context menu, the cursor hovers over "Expand Whole File".

Selecting changes to include in a commit

As you make changes to files in your text editor and save them locally, you will also see the changes in GitHub Desktop.

In the "Changes" tab in the left sidebar:

  • The red icon indicates removed files.

  • The yellow icon indicates modified files.

  • The green icon indicates added files.

  • To access stashed changes, click Stashed Changes.

  • Para agregar todos los cambios en todos los archivos en una única confirmación, mantenga activada la casilla de la parte superior de la lista.

    Screenshot of the "Changes" tab. Above the list of changed files, next to the text "3 changed files", a selected checkbox is outlined in orange.

  • Para agregar todos los cambios en uno o más archivos a una confirmación única, desactive las casillas situadas junto a los archivos que no quiera incluir y deje seleccionados solamente los que quiera incluir en la confirmación. Puede alternar la casilla con las teclas Spacebar o Enter después de seleccionar un archivo.

Creating a partial commit

If one file contains multiple changes, but you only want some of those changes to be included in a commit, you can create a partial commit. The rest of your changes will remain intact, so that you can make additional modifications and commits. This allows you to make separate, meaningful commits, such as keeping line break changes in a commit separate from code or prose changes.

To exclude changed lines from your commit, click one or more changed lines so the blue disappears. The lines that are still highlighted in blue will be included in the commit.

Screenshot of the diff view of a text file. Next to the text "I don't want to include this line", the background color behind the line numbers is green, not blue.

Discarding changes

If you have uncommitted changes that you don't want to keep, you can discard the changes. This will remove the changes from the files on your computer. You can discard all uncommitted changes in one or more files, or you can discard specific lines you added.

Discarded changes are saved in a dated file in the Trash. You can recover discarded changes until the Trash is emptied.

Discarding changes in one or more files

  1. En la lista de archivos cambiados, selecciona los archivos en los que deseas descartar los cambios desde la última confirmación. Para seleccionar varios archivos, haga clic en shift y después en el rango de archivos de los que quiera descartar los cambios.

  2. Haga clic en Discard Changes (Descartar cambios) o en Discard Selected Changes (Descartar los cambios seleccionados) para descartar los cambios realizados en uno o más archivos, o en Discard All Changes (Descartar todos los cambios) para descartar los cambios realizados en todos los archivos desde la última confirmación.

    Screenshot of the "Changes" tab. Two selected files are highlighted in blue. In a context menu, the cursor hovers over "Discard 2 Selected Changes".

  3. Para confirmar los cambios, en la ventana "Confirmar cambios de descarte", revisa los archivos afectados y haz clic en Descartar cambios.

Discarding changes in one or more lines

You can discard one or more changed lines that are uncommitted.

Note: Discarding single lines is disabled in a group of changes that adds and removes lines.

To discard one added line, in the list of changed lines, right-click the line number of the line you want to discard, then select Discard Added Line.

Screenshot of the diff view of a file. In a context menu, a cursor hovers over "Discard Added Line", highlighted in blue.

To discard a group of changed lines, right-click the vertical bar to the right of the line numbers for the lines you want to discard, then select Discard added lines.

Screenshot of the diff view of a file. To the right of the line numbers, a narrow, darker blue line is highlighted with an orange outline.

Write a commit message and push your changes

Once you're satisfied with the changes you've chosen to include in your commit, write your commit message and push your changes. If you've collaborated on a commit, you can also attribute a commit to more than one author.

Note: Predeterminadamente, GitHub Desktop cargará la etiqueta que creaste a tu repositorio con la confirmación asociada. For more information, see "Managing tags in GitHub Desktop."

  1. En la parte inferior de la lista de cambios, en el campo Summary (Resumen), escribe un mensaje de confirmación corto y significativo. De forma opcional, puedes añadir más información sobre el cambio en el campo Description (Descripción).

    Screenshot of the "Changes" tab in the sidebar. To the right of a profile picture, a text field containing a commit message is outlined in orange.

  2. Optionally, to attribute a commit to another author, click the add co-authors icon and type the username(s) you want to include.

    Screenshot of the "Changes" tab. In the corner of the "Description" field, a "person with a plus sign" icon for adding a co-author is outlined in orange.

  3. En el campo Descripción, haz clic en Confirmar en RAMA.

  4. If the branch you're trying to commit to is protected, Desktop will warn you.

    • To move your changes, click switch branches.
    • To commit your changes to the protected branch, click Commit to BRANCH.

    For more information about protected branches, see "Acerca de las ramas protegidas."

  5. Para insertar los cambios locales en el repositorio remoto, en la barra del repositorio, haz clic en Insertar origen.

    Captura de pantalla de la barra del repositorio. Un botón, con la etiqueta "Insertar origen", está resaltado con un contorno naranja.

  6. If you have a pull request based off the branch you are working on, GitHub Desktop will display the status of the checks that have run for the pull request next to the "Current Branch" section of the repository bar. For more information about checks, see "Viewing and re-running checks in GitHub Desktop."

    If a pull request has not been created for the current branch, GitHub Desktop will give you the option to preview the changes and create one. For more information, see "Creating an issue or pull request from GitHub Desktop."

    Screenshot of the "No local changes" view. A button, labeled "Preview Pull Request", is highlighted with an orange outline.

Further reading