Inicio·Comandos de terminal

git push

git

Uso

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

Envía tus commits a un remoto; --force sobrescribe la rama remota y puede borrar commits de otros, así que usa --force-with-lease, que se niega si el remoto cambió.

Opciones habituales

OpciónSignificado
-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

Ejemplos

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

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

Envía tus commits a un remoto; --force sobrescribe la rama remota y puede borrar commits de otros, así que usa --force-with-lease, que se niega si el remoto cambió.

Q. ¿Cómo se escribe?

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