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.

Managing branches

You can create a branch off of a repository's default branch so you can safely experiment with changes.

En este artículo

About managing branches

You can use branches to safely experiment with changes to your project. Branches isolate your development work from other branches in the repository. For example, you could use a branch to develop a new feature or fix a bug.

You always create a branch from an existing branch. Typically, you might create a branch from the master branch of your repository. You can then work on this new branch in isolation from changes that other people are making to the repository.

Once you're satisfied with your work, you can open a pull request to merge the changes in the current branch into another branch. For more information, see "About pull requests."

You can always create a branch in GitHub Desktop if you have read access to a repository, but you can only push the branch to GitHub if you have write access to the repository.

Repository administrators can enable protections on a branch. If you're working on a branch that's protected, you won't be able to delete or force push to the branch. Repository administrators can enable other protected branch settings to enforce specific workflows before a branch can be merged. For more information, see "About protected branches."

Creating a branch

Tip: The first new branch you create will be based on the default branch, which is usually master. If you have more than one branch, you can choose to base the new branch on the currently checked out branch or the default branch.

  1. En la parte superior de la aplicación, cambia a la rama en la que deseas basar la nueva rama haciendo clic en Current Branch (Rama actual) y selecciónala dentro de la lista.
    Drop-down menu to switch your current branch
  2. Haz clic en New Branch (Nueva rama).
    New Branch option in the Branch menu
  3. Dentro de Name (Nombre), escribe el nombre de la nueva rama.
    Field for creating a name for the new branch
  4. Selecciona la rama actual o la rama por defecto (por lo general, la rama principal) en la que se basará la nueva rama.
    Base branch options
  5. Haz clic en Create Branch (Crear rama).
    Create Branch button
  1. En la parte superior de la aplicación, cambia a la rama en la que deseas basar la nueva rama haciendo clic en Current Branch (Rama actual) y selecciónala dentro de la lista.
    Drop-down menu to switch your current branch
  2. Haz clic en New Branch (Nueva rama).
    New Branch option in the Branch menu
  3. Dentro de Name (Nombre), escribe el nombre de la nueva rama.
    Field for creating a name for the new branch
  4. Selecciona la rama actual o la rama por defecto (por lo general, la rama principal) en la que se basará la nueva rama.
    Base branch options
  5. Haz clic en Create Branch (Crear rama).
    Create branch button

Switching between branches

You can view and make commits to any of your repository's branches. If you have uncommitted, saved changes, you'll need to decide what to do with your changes before you can switch branches. You can commit your changes on the current branch, stash your changes on the current branch, or bring the changes to your new branch. If you want to commit your changes on the current branch, follow the steps in "Committing and reviewing changes to your project" before switching branches.

Tip: You can set a default behavior for switching branches in the Advanced settings. For more information, see "Configuring basic settings."

  1. En la parte superior de la aplicación, haz clic en Current Branch (Rama actual).
    Menú desplegable de la rama actual
  2. Dentro de la lista de ramas, haz clic en la rama a la que deseas cambiar para continuar.
    List of branches in the repository
  3. If you have saved, uncommitted changes, choose Leave my changes or Bring my changes, then click Switch Branch.
    Switch branch with changes options

Retrieving stashed changes

To access changes you've stashed in another branch, switch back to the branch you stashed the changes in.

  1. En la parte superior de la aplicación, haz clic en Current Branch (Rama actual).
    Menú desplegable de la rama actual
  2. Dentro de la lista de ramas, haz clic en la rama a la que deseas cambiar para continuar.
    List of branches in the repository
  3. In the left sidebar, click Stashed Changes.
    Stashed changes option
  4. To delete your stashed changes, click Discard, or to use your stashed changes, click Restore.
    Discard or Restore stashed changes

Deleting a branch

You can't delete a branch if it's currently associated with an open pull request. You cannot undo deleting a branch.

  1. At the top of the app, click Current Branch, then click the branch that you want to delete.
    Drop-down menu to select which branch to delete
  2. In your menu bar, click Branch, then click Delete.... You can also press shift⌘ commandD.
    Delete... option in the Branch menu
  1. At the top of the app, click Current Branch, then click the branch that you want to delete.
    Drop-down menu to select which branch to delete
  2. In your menu bar, click Branch, then click Delete.... You can also press CtrlShiftD.
    Delete... option in the Branch menu

Further reading

Pregunta a una persona

¿No puedes encontrar lo que estás buscando?

Contáctanos