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 is currently under limited release. Please contact our Sales Team to find out more.

Moving a file to a new location using the command line

You can use the command line to move files within a repository by removing the file from the old location and then adding it in the new location.

Many files can be moved directly on GitHub Enterprise, but some files, such as images, require that you move them from the command line.

Este procedimiento supone que ya has:

  1. On your computer, move the file to a new location within the directory that was created locally on your computer when you cloned the repository.
  2. Abre la TerminalTerminalGit Bash.
  3. Use git status to check the old and new file locations.
    $ git status
    > # On branch your-branch
    > # Changes not staged for commit:
    > #   (use "git add/rm ..." to update what will be committed)
    > #   (use "git checkout -- ..." to discard changes in working directory)
    > #
    > #     deleted:    /old-folder/image.png
    > #
    > # Untracked files:
    > #   (use "git add ..." to include in what will be committed)
    > #
    > #     /new-folder/image.png
    > #
    > # no changes added to commit (use "git add" and/or "git commit -a")
  4. Prepara el archivo para confirmarlo para tu repositorio local. This will delete, or git rm, the file from the old location and add, or git add, the file to the new location.
    $ git add .
    # Adds the file to your local repository and stages it for commit.
    # Para deshacer un archivo, usa 'git reset HEAD YOUR-FILE'.
  5. Use git status to check the changes staged for commit.
    $ git status
    > # On branch your-branch
    > # Changes to be committed:
    > #   (use "git reset HEAD ..." to unstage)
    > #
    > #    renamed:    /old-folder/image.png -> /new-folder/image.png
    # Displays the changes staged for commit
  6. Confirma el archivo que has preparado en tu repositorio local.
    $ git commit -m "Move file to new directory"
    # Commits the tracked changes and prepares them to be pushed to a remote repository.
    # Para eliminar esta confirmación y modificar el archivo, usa 'git reset --soft HEAD~1' y confirma y agrega nuevamente el archivo.
  7. Sube los cambios en tu repositorio local a tu instancia de servidor de GitHub Enterprise.
    $ git push origin your-branch
    # Pushes the changes in your local repository up to the remote repository you specified as the origin

Further reading

¿Te ayudó este documento?

Privacy policy

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

O, learn how to contribute.