Sinopsis
git pack-objects [--stdout] [--all] <base-name> < <object-list>
Descripción
El comando git pack-objects es plumbing que crea archivos pack: contenedores comprimidos con compresión delta de muchos objetos en un solo archivo. Los packs son cómo Git almacena objetos eficientemente y los transfiere por la red.
Normalmente invocado por git gc, git repack y operaciones de fetch/push. Los usuarios rara vez lo invocan directamente.
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
You almost never invoke this directly. git gc, git repack, and the network protocol drive it for you. Reach for it manually when implementing custom transport, optimizing storage, or experimenting with delta strategies.
Opciones comunes
| Opción | Descripción |
|---|---|
--stdout | Write the pack to stdout instead of files. |
--all | Pack everything reachable from any ref. |
--revs | Read revisions from stdin instead of object SHAs. |
--depth=<n> | Maximum delta chain depth. |
--window=<n> | Window size for delta search. |
--thin | Allow thin packs (deltas against external objects). |
--no-reuse-delta | Recompute deltas instead of reusing existing. |
Ejemplos
git rev-list --objects --all | git pack-objects --stdout > everything.pack
# Build a single pack of every reachable object
git rev-list --objects HEAD ^origin/main | \
git pack-objects --thin --stdout > ahead.pack
# A thin pack of just the commits ahead of origin/main
git pack-objects --all .git/objects/pack/extra
# Repack all reachable objects into a new pack named "extra"
Errores comunes
Building large packs with --depth and --window set too high consumes lots of memory and CPU. The defaults from git gc are sensible for most repos. Producing thin packs without context (an existing repo to apply them to) is useless.
Comandos relacionados
git unpack-objects, git verify-pack, git gc, git repack