Início·Comandos de terminal

git remote

git

Uso

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

Gerencia os nomes e as URLs dos repositórios remotos; só anota, nada trafega até você fazer fetch ou push.

Opções comuns

OpçãoSignificado
-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

Exemplos

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

O confuso é que desfazer tem várias formas: mover para onde um branch aponta não é o mesmo que criar um commit que reverte.

Como ler

  • Os colchetes [ ] marcam uma parte que você pode omitir.
  • As reticências … indicam que você pode listar vários.
  • As opções diferenciam maiúsculas: em alguns comandos -r e -R fazem coisas diferentes.

Perguntas

Q. O que git remote faz?

Gerencia os nomes e as URLs dos repositórios remotos; só anota, nada trafega até você fazer fetch ou push.

Q. Como se digita?

git remote -v | git remote add <name> <url> — os colchetes marcam o que você pode omitir.

Q. Quantas opções vale a pena saber?

Aqui estão 7; a lista completa está em man git. Este comando fica em git.

Comandos relacionados

página man: man git-remote