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 fetch

git

Uso

git fetch [--all] [--prune] [<remote> [<branch>]]

Descarga los commits nuevos sin tocar tus archivos ni tu rama, así que aún falta un merge o rebase, y las ramas borradas en el servidor siguen ahí hasta --prune.

Opciones habituales

OpciónSignificado
--allfrom every remote
--prunedelete tracking refs whose branch is gone on the server
--tagsalso fetch tags
--unshallowfill in the history a --depth clone left out
--depth <n>deepen a shallow clone by n commits
-fupdate a ref even when it is not a fast-forward

Ejemplos

git fetch --all --prune

refreshes every remote and clears dead branches

git fetch origin main

updates origin/main without touching your files

git fetch --unshallow

turns a shallow clone into a full one

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

Descarga los commits nuevos sin tocar tus archivos ni tu rama, así que aún falta un merge o rebase, y las ramas borradas en el servidor siguen ahí hasta --prune.

Q¿Cómo se escribe?

git fetch [--all] [--prune] [<remote> [<branch>]] — los corchetes marcan lo que puedes omitir.

Q¿Cuántas opciones vale la pena saber?

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

Comandos relacionados

página man: man git-fetch