Sinopsis
git maintenance start
git maintenance run [--task=<task>]
git maintenance stop
Descripción
El comando git maintenance (Git 2.29+) consolida múltiples tareas de mantenimiento (gc, commit-graph, repack incremental, prefetch) en un único comando que puede registrarse para ejecución programada.
git maintenance start registra un trabajo de cron/launchd/systemd que mantiene el repo optimizado en segundo plano sin intervención del usuario.
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.
Opciones comunes
| Subcommand / Option | Description |
|---|---|
start | Register a background schedule. |
stop | Unregister the schedule. |
run | Run tasks immediately. |
--task=<task> | Run only this task (commit-graph, prefetch, etc.). |
register / unregister | Add or remove repo from the maintenance set. |
--schedule=<freq> | Frequency: hourly, daily, weekly. |
Ejemplos
git maintenance start
# Set up background maintenance for this repo
git maintenance run --task=commit-graph
# Update the commit-graph on demand
git maintenance run --task=prefetch
# Fetch upstream objects without updating refs
git maintenance unregister
# Stop scheduled maintenance for this repo
Errores comunes
Forgetting that start registers a system-wide scheduled task. On shared machines, this might not be what you want; use register in a config file instead. Disabling automatic gc but not enabling maintenance leaves the repo to grow unchecked.
Comandos relacionados
git gc, git commit-graph, git fetch --prefetch, git repack