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ón | Significado |
|---|---|
| -u | set the upstream so later pushes need no arguments |
| --force-with-lease | force, but stop if the remote moved since your last fetch |
| -f | force: overwrite the remote branch, commits of others included |
| --tags | push tags as well, which push does not do on its own |
| --delete <branch> | delete the branch on the server |
| --all | push every local branch |
| -n | dry run |
Ejemplos
git push -u origin feature/loginpublishes the branch and remembers the pairing
git push --force-with-leasethe safe force, used after a rebase
git push origin --delete old-featureremoves 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