Inicio·Comandos de terminal
Publicidad

Consigue tu bono en un exchange de criptomonedas

Bonos que recibes solo por registrarte. Las condiciones son las que publica cada exchange.

git remote

git

Uso

git remote -v | git remote add <name> <url>

Gestiona los nombres y las URL de los repositorios remotos; solo los apunta, nada viaja hasta que haces fetch o push.

Opciones habituales

OpciónSignificado
-vlist the remotes with their URLs
add <name> <url>register another repository
set-url <name> <url>point an existing remote somewhere else
rename <old> <new>rename a remote
remove <name>forget a remote
show <name>branches it has and how they are tracked
prune <name>drop tracking refs for branches deleted there

Ejemplos

git remote -v

shows the fetch and push URL of every remote

git remote add upstream https://github.com/orig/repo.git

adds the original repo alongside your fork

git remote set-url origin git@github.com:me/repo.git

switches origin from HTTPS to ssh

Lo confuso es que deshacer tiene varias formas: mover a dónde apunta una rama no es lo mismo que añadir un commit que la revierte.

Cómo leerlo

  • Los corchetes [ ] marcan una parte que puedes omitir.
  • Los puntos suspensivos … indican que puedes poner varios.
  • Las opciones distinguen mayúsculas: en algunos comandos -r y -R no hacen lo mismo.

Preguntas

Q¿Qué hace git remote?

Gestiona los nombres y las URL de los repositorios remotos; solo los apunta, nada viaja hasta que haces fetch o push.

Q¿Cómo se escribe?

git remote -v | git remote add <name> <url> — los corchetes marcan lo que puedes omitir.

Q¿Cuántas opciones vale la pena saber?

Aquí van 7; la lista completa está en man git. Este comando está en git.

Comandos relacionados

página man: man git-remote