Sinopsis
git rev-list [<options>] <commit>...
Descripción
El comando git rev-list lista commits alcanzables desde una o más refs, en orden cronológico inverso. Es la base plumbing detrás de git log sin el formato amigable.
Útil cuando solo necesitas SHAs (no contenido formateado), o para contar commits con --count. Combinado con --ancestry-path, identifica el camino exacto entre dos commits.
En el uso diario, este comando se integra estrechamente con alias de shell, plugins de editor e integración continua. Los usuarios avanzados a menudo añaden alias que combinan los flags que siempre pasan. El formato de salida puede personalizarse vía configuración de Git. Cuando algo sale mal, ejecuta el comando con GIT_TRACE=1 para revelar las llamadas plumbing subyacentes.
Entender cómo este comando interactúa con el resto del modelo de datos de Git rinde dividendos. Cada comando opera sobre algún subconjunto de las piezas (objetos, index, refs, árbol de trabajo), y saber cuáles toca ayuda a predecir resultados y a recuperarse de errores.
Cuándo usar
Power users and toolsmiths use rev-list in scripts. Day-to-day developers use git log, which is built on top of rev-list but produces human-friendly output.
Opciones comunes
| Opción | Descripción |
|---|---|
--count | Print just the number of commits. |
--max-count=<n> | Limit how many commits to list. |
--reverse | Output oldest first. |
--no-merges | Exclude merge commits. |
--first-parent | Follow only the first parent of each merge. |
--ancestry-path | Restrict to commits between two endpoints. |
--all | Include every ref as a starting point. |
Ejemplos
git rev-list --count HEAD
# Total number of commits reachable from HEAD
git rev-list main..feature
# SHAs unique to feature
git rev-list --no-merges --since="1 month ago" main
# Non-merge commits in the last month
git rev-list --max-parents=0 HEAD
# Find root commits (no parents)
Errores comunes
Forgetting that ranges with two dots exclude commits reachable from the left side. --first-parent changes the meaning of "ancestry" significantly. On huge repos, unbounded rev-list can be slow — pair with --max-count or path filters.
Comandos relacionados
git log, git rev-parse, git merge-base, git bisect