Pourquoi maintenance, pas gc
git maintenance (Git 2.31+) est le remplaçant moderne orienté tâches pour gc --auto. Il exécute des tâches spécifiques (commit-graph, prefetch, incremental-repack, loose-objects, pack-refs, gc) sur des plannings adaptés à chacune, en arrière-plan, sans bloquer vos commandes interactives.
Démarrer
git maintenance start
git maintenance start --scheduler=systemd
git maintenance start --scheduler=launchctl
git maintenance start --scheduler=schtasks
Inspecter et arrêter
git maintenance status
git maintenance stop
git maintenance unregister
Tâches et plannings
| Tâche | Planning par défaut | Ce qu'elle fait |
|---|---|---|
| commit-graph | horaire | Met à jour le commit-graph |
| prefetch | horaire | Fetch dans des refs cachées |
| loose-objects | quotidien | Empaquette objets loose |
| incremental-repack | quotidien | Repack géométrique + MIDX |
| pack-refs | hebdomadaire | Empaquette refs loose |
| gc | off par défaut | gc complet ; préférer les autres |
Exécutions manuelles
git maintenance run --task=commit-graph
git maintenance run --task=incremental-repack
git maintenance run --auto
Config par tâche
[maintenance]
auto = false
strategy = incremental
[maintenance "commit-graph"]
enabled = true
[maintenance "incremental-repack"]
enabled = true
auto = 100
[maintenance "loose-objects"]
enabled = true
batchSize = 50
Désactiver auto-gc
git config gc.auto 0
Erreurs courantes
Oublier git maintenance start après cloner un gros repo.
Logs
Sur systemd : journalctl --user -u git-maintenance.service. Sur macOS : ~/Library/Logs/git-maintenance.log.