Início·Comandos de terminal

git push

git

Uso

git push [-u] [--force-with-lease] <remote> <branch>

Envia seus commits para um remoto; --force sobrescreve o branch remoto e pode apagar commits de outras pessoas, então use --force-with-lease, que recusa se o remoto andou.

Opções comuns

OpçãoSignificado
-uset the upstream so later pushes need no arguments
--force-with-leaseforce, but stop if the remote moved since your last fetch
-fforce: overwrite the remote branch, commits of others included
--tagspush tags as well, which push does not do on its own
--delete <branch>delete the branch on the server
--allpush every local branch
-ndry run

Exemplos

git push -u origin feature/login

publishes the branch and remembers the pairing

git push --force-with-lease

the safe force, used after a rebase

git push origin --delete old-feature

removes the branch on the server

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 push faz?

Envia seus commits para um remoto; --force sobrescreve o branch remoto e pode apagar commits de outras pessoas, então use --force-with-lease, que recusa se o remoto andou.

Q. Como se digita?

git push [-u] [--force-with-lease] <remote> <branch> — 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-push