Inicio·Comandos de terminal

git show

git

Uso

git show [<object>|<commit>:<path>]

Imprime un commit con su mensaje y su diff; la forma <commit>:<ruta> saca una versión antigua del archivo sin tocar tu copia de trabajo.

Opciones habituales

OpciónSignificado
--statfile summary instead of the full patch
--name-onlylist the paths the commit touched
-smessage only, no diff
<commit>:<path>print the file as it was in that commit
--pretty=fullershow author and committer dates separately

Ejemplos

git show HEAD

the message and diff of the last commit

git show HEAD~2:src/app.ts

prints an old version of a file without touching your copy

git show --stat v1.2.0

what the tagged commit changed, file by file

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

Imprime un commit con su mensaje y su diff; la forma <commit>:<ruta> saca una versión antigua del archivo sin tocar tu copia de trabajo.

Q. ¿Cómo se escribe?

git show [<object>|<commit>:<path>] — los corchetes marcan lo que puedes omitir.

Q. ¿Cuántas opciones vale la pena saber?

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

Comandos relacionados

página man: man git-show