git show para coding agents: objeto concreto, no el parche al LLM
Resumen
git show imprime un objeto (commit, tag, tree o blob). En un commit, el default es mensaje + diff. Un agente usa --stat / --name-only / -s --format; no vuelca el parche. Git 2.50.1.

Qué resuelve
Esta pieza se queda en la decisión práctica: qué instalar, qué riesgo agrega y cómo aplicarlo sin romper operación.
git show no es un walk de historia ni un diff de dos extremos. El man (git-show(1), Git 2.50.1 / Apple Git-155; git-scm.com/docs/git-show HTTP 200, last-modified 2026-08-31): muestra uno o más objetos — blobs, trees, tags y commits. Sin <object>: HEAD. HEAD, index y working tree no se mueven.
Por tipo:
- Commit: mensaje + diff textual. Un merge sale en el formato de
git diff-tree --cc. - Tag: mensaje del tag y el objeto al que apunta.
- Tree: nombres, equivalente a
git ls-tree --name-only. - Blob: el contenido crudo.
Esta guía no sustituye log (conjuntos de commits) ni diff (dos extremos). El contrato: qué forma corre un agente, qué flags fuerzan, y por qué el default inunda el contexto.
Un objeto, no un rango
El man: <object>... son nombres de objeto. Cómo se escriben: SPECIFYING REVISIONS en gitrevisions(7) (git-scm.com/docs/gitrevisions HTTP 200). HEAD, un SHA, v1.2^{commit}, HEAD:src/foo.ts (blob), HEAD^{tree}.
-- delante de paths. git show HEAD -- src/foo.ts no se confunde si existe una rama src.
GitHub Docs (Comparing commits, HTTP 200 2026-09-04): la UI /compare elige base y compare. No es git show. Un agente que quiere “qué metió este SHA” corre git show; el que quiere “qué introduce el topic vs main” corre diff three-dot o log A..B.

Lo que el agente sí / no corre
| Quiero | Comando | Trampa |
|---|---|---|
| ¿Qué tocó este SHA? | git show --stat --format='%h %s' <sha> | git show <sha> crudo al LLM |
| ¿Qué paths? | git show --name-only --format='%h %s' <sha> | --pretty sin -s (el parche sigue) |
| Solo metadatos | git show -s --format='%h %an %s' <sha> | Default medium + patch |
| Blob de un path | git show <sha>:<path> | Dump binario |
| Merge compacto | git show --cc --stat <sha> | -m sin -p (el man: -m no emite diff si no hay -p) |
Prohibido en autónomo:
- Volcar
git show/git show HEADsin--stat/--name-only/--name-status/-sal prompt. El man: en un commit, el default incluye el diff. Verificado 2026-09-04 (Git 2.50.1 / Apple Git-155):git show --format='%h %s' HEADsigue emitiendo el parche (6 líneas en un commit de 1 archivo).-s/--no-patchlo apaga. --pretty/--formatsin-scomo “solo el mensaje”. El man (DIFF FORMATTING):-ssuprime la maquinaria de diff;--formatsolo cambia el log.--show-signature. Pasa la firma agpg --verify. Sin clave/agente, ruido o hang. Un agente no verifica GPG por default.--notesextra / dumps de notes refs. El man: notes se muestran por default si no hay--pretty/--format/--oneline. Con--formatya no. No las pidas.- Blob binario al LLM (
HEAD:foo.png, objeto con NUL). El man: plain contents. Verificado aquí:git show HEAD:bin.datemite los bytes, exit 0. - Varios
<object>a la vez “para ahorrar”. Cada uno puede traer su parche. - Pager.
pager.showaplica. Un agente fijaGIT_PAGER=cato--no-pager.
Objeto inexistente: exit 128. Verificado: SHA inventado → fatal: bad object, 128; rev nosuch → fatal: ambiguous argument ... unknown revision or path, 128. No reintentes con otro SHA adivinado.
Receta (60 segundos)
Solo en un worktree propio:
git rev-parse --verify "${sha}^{commit}"
git show --stat --format='%h %an %s' -- "$sha"
git show --name-status --format='%h %s' -- "$sha"
Si el humano pidió un path:
git show --stat --format='%h %s' "$sha" -- "$path"
Si solo hace falta el subject:
git show -s --format='%h %s' "$sha"
--oneline = --pretty=oneline --abbrev-commit. Sigue yendo con parche salvo -s.

Show vs log vs diff vs GitHub compare
| Pregunta | Comando | No |
|---|---|---|
| Este SHA, ¿qué cambió? | git show --stat <sha> | git log -p -1 al LLM |
| ¿Qué commits hay en el topic? | log A..B | git show A..B (no es un walk) |
| ¿Qué introduce el PR? | diff A...B | git show del tip (un commit, no el rango) |
| UI de GitHub | /compare base…compare | Sustituir git show |
Un merge: el man usa --cc (dense combined) por default, salvo --first-parent. -m no imprime diffs de merge sin -p. --no-diff-merges apaga el parche del merge; el mensaje queda.
--abbrev-commit acorta el SHA. --no-abbrev-commit fuerza 40 hex. Un agente que parsea usa --format='%H' (completo) o '%h' (abbrev), no recorta a mano.
Checklist
- Worktree propio. Objeto pedido por el humano o leído de status / log, no adivinado.
-
git rev-parse --verifyexit 0 antes. 128 = no existe; para. -
--stat/--name-status/-s --format. Cero parche crudo al LLM. - Paths detrás de
--. - Cero
--show-signature, blob binario, varios objetos a ciegas. - Cero pager. Cero
git showcomo si fuera diff three-dot.
FAQ
¿git show sin args? HEAD. En un repo sucio no incluye unstaged: el working tree no entra. Para unstaged: diff.
¿--format ya quita el diff? No. Verificado: --format='%h %s' deja el parche. Hace falta -s.
¿Puedo git show v1? Sí: es un tag. El man imprime el mensaje del tag y el objeto referenciado (a menudo otro commit + su diff). Acota con -s o --stat.
¿git show HEAD:archivo en vez de leer el working tree? Eso es el blob commiteado, no el archivo sucio. No lo uses para “ver lo que estoy editando”.
El curso instalar un agente cubre el loop local. Hub: comparativas y decisiones. Show no es log: imprime un objeto, no resta conjuntos.
Verificado 2026-09-04 contra git-show(1) (Git 2.50.1 / Apple Git-155; git-scm.com/docs/git-show HTTP 200, last-modified 2026-08-31), gitrevisions(7) (HTTP 200) y GitHub Docs “Comparing commits” (HTTP 200; /compare es base/compare, no git show). En esta máquina: objeto inexistente exit 128; --format sin -s emite parche; -s --format no; blob binario sale crudo.
Lecturas relacionadas
Sigue explorando Coding Agents y otras piezas para builders.



